PDA

View Full Version : Solved: Code in a macro that changes a file location



Giuliar
06-08-2008, 08:09 AM
Hello

I am a VBA dabbler and not very good at it but a couple of years ago, I created a letterhead template for my office in Word 2K. It has a macro in it that gets user information from an .ini file which is stored in the users "my documents" folder. The office is now upgrading our hardware and software, so the IT administrators tell me I need to change the location of my .ini file to a network drive. I don't know how to write the code to change the file from the default "my documents" folder to a new network drive folder. Can someone please take a look at the code below and give me some suggestions on how to change the .ini file location. The code I am looking to change is in red. Thanks.


Sub letterhead()
'
' Letterhead Macro
'
'Declare variables
Dim strFile As String
Dim strUsername As String
Dim strUsertitle As String
Dim strUserphone As String
Dim strUseremail As String
strFile = Options.DefaultFilePath(wdDocumentsPath) & "\Data.ini"
strUsername = System.PrivateProfileString(strFile, "Info",
"Username")
strUserphone = System.PrivateProfileString(strFile, "Info",
"Userphone")
strUseremail = System.PrivateProfileString(strFile, "Info",
"Useremail")
strUsertitle = System.PrivateProfileString(strFile, "Info",
"Usertitle")

ActiveDocument.Bookmarks("Username").Range.Text = strUsername
ActiveDocument.Bookmarks("Usertitle").Range.Text = _
strUsertitle
ActiveDocument.Bookmarks("Userphone").Range.Text = strUserphone
ActiveDocument.Bookmarks("Useremail").Range.Text = _
strUseremail

Selection.GoTo What:=wdGoToBookmark, Name:="start"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
ActiveWindow.View.ShowBookmarks = False
End Sub

fumei
06-09-2008, 06:14 AM
You marked this as Solved with no replies. Is it in fact Solved? If so, please post what you did to solve it.

Thanks.

Chukesgirl
06-09-2008, 12:31 PM
I had the same problem.

Change the folder location to
strFile = "drive letter:\Data.ini"

fumei
06-09-2008, 12:33 PM
Thanks.