I'm trying to modify a file that opens on startup. It's location would change from user to user. How do I get the path of the file that's already open? Thanks
I'm trying to modify a file that opens on startup. It's location would change from user to user. How do I get the path of the file that's already open? Thanks
Depends on the file type. But you can get the startup folder path like so:
Path = "C:\Documents and Settings\" & vba.Environ$("USERNAME") & "\Start Menu\Programs\Startup\"
Thanks, I'll give it a shot. You don't happen to know anything about MSProject and global.mpt, do you? I sure could use some help. Thanks again.
I know project. What are you trying to do?
Aaron,
FWIW, I'd go with something like [vba]msgbox environ("userprofile") & "\start menu\programs\startup\"[/vba]As stupid as I think it is, some people (or businesses) change where their user files are located.
Also, checking the All Users directory (environ("allusersprofile")) for the startup file might not be a bad idea too, again depending on the setup.
Matt
I'm trying to add an open event to the global.mpt without overriding the existing file. I have a set of toolbars and menus that I want created / deleted when global.mpt is opened.
My company is one that moves the default startup directory. Thanks!
I used the Environ$(username) and it worked fine for my test machine, but it died on mine because my username has been changed since the originial install. How would I go about checking that, then giving a browse button / window for the user if it can't be found? Thank you!!
Did you try the user profile like Matt suggested? It's actually the better way to go.
I get runtime error 52, bad filename or number.
[VBA]"C:\Documents and Settings\" & VBA.Environ("USERprofile") & "\Application Data\Microsoft\MS Project\11\1033\global.mpt"[/VBA] It's just a file copy statement. I can't post the whole thing because it has my company info in it... Thanks again.
Ahh well there is your problem then. USERPROFILE contains the path up to the username. To see what I am refering to do [vba]MsgBox VBA.Environ("USERprofile")[/vba] All you really need to do is:[vba]VBA.Environ("USERprofile") & "\Application Data\Microsoft\MS Project\11\1033\global.mpt"[/vba]You know there may be an easier way to go about this... What application are you hosting this code in?
Can you hear me dancing around like a fool??? It worked perfectly. Thank you so much. That would have taken forever to figure out!:>