I'm working with MS Excel 2010.
I also posted this question on the MR. Excel sight.
How do I read/write to a file in c:\users\myusername\My Documents ?
Open "%UserProfile%\My Documents" For Output As #1 is the closest I can guess in VBA.
In UFT I can use Environment("UserName") and build the string. I don't have that in VBA. Is there another way to get the User Name?
%UserProfile%\My Documents is a native windows shortcut should work fine in your UFT script too.
If you want the path of the current users 'My Documents' folder, there is a convenient mechanism built in to WSH called "Special Folders"
You do not need the user name of the current user.
For completeness I'll try and answer both questions.
The code below works in VBScript.
set this = CreateObject("WScript.Shell")
set that = CreateObject("WScript.Network")
myDocuments = this.SpecialFolders("MyDocuments") &"\"
myUserName = that.UserName
you'll be able to do something very similar in VBA
... just another Tester ...
Your information is appreciated.
UserName = Environ("UserName")