PDA

View Full Version : Solved: Environ("USERNAME") - Can't find Project or Library error



starsky
07-02-2012, 05:14 AM
Hi,

We send out files for montlhy completion to many users in our organisation. One short piece of code lets us know that, even if they don't add data, they are confirming that they are not adding data (as opposed to ignoring the file completely).

Everything was compiled in 2003, and has worked fine. However, there is an upgrade process underway. One user with 2010 gets a "Can't find project or library" error when trying to run this, Environ is highlighted. Other code in the workbook has worked successfully for them. Another 2010 user had no such problem.

Any ideas or alternatives?

Sub usern()
ActiveSheet.Range("G3").Value = Environ("USERNAME") & " " & Now
ThisWorkbook.Save
End Sub

Many thanks.

Kenneth Hobs
07-02-2012, 05:29 AM
It is probably a library issue. Check for the word Missing in one of his Tools > References.

You could try this:
Sub usern()
ActiveSheet.Range("G3").Value = VBA.Environ("username") & " " & Now
ThisWorkbook.Save
End Sub

starsky
07-02-2012, 05:59 AM
Thanks Kenneth, the user has reported that your amended code produced no error.

Bob Phillips
07-02-2012, 07:08 AM
You should also check Tools>References as Kenneth suggested, it might manifest in another problem later.