Consulting

Results 1 to 4 of 4

Thread: Solved: Code in a macro that changes a file location

  1. #1
    VBAX Newbie
    Joined
    Jun 2008
    Posts
    5
    Location

    Question Solved: Code in a macro that changes a file location

    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

  2. #2
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    You marked this as Solved with no replies. Is it in fact Solved? If so, please post what you did to solve it.

    Thanks.

  3. #3
    I had the same problem.

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

  4. #4
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •