Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    Portland, Maine, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SystemDrive (Word 2002 SP2)

    In my login script I use the environment variable %SystemDrive% to copy my workgroup templates to the local drive. I do this for two reasons. 1. Notebook users can still work even if offline. 2. When I want to make a change to a template, it is never in use on the network. I make the change and at next login, everyone gets the udpate. I also copy a global template to the Word startup folder so I can easily distribute macros, etc. A sample of the relevant lines from my login script follow.

    xcopy "I:templatesglobalglobal.dot" "%APPDATA%microsoftwordstartup" /c /y /i
    xcopy "i:templatesworkgroup*.*" %systemdrive%templates /s /q /i /C /y

    I use the %systemdrive% variable in the login script to both account for my terminal server users and in case someone does not use C: as their system drive. In this particular environment I do not have group policy available to set the location of files for workgroup templates to %systemdrive%templates. I have an autoexec macro in my global.dot that I want to use to set the workgroup template location:Options. DefaultFilePath(wdWorkgroupTemplatesPath) = "C:templates"

    Now the question ... How can I access this (or a similar) variable from VBA code?

  2. #2
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    Portland, Maine, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SystemDrive (Word 2002 SP2)

    And then it dawned on me ... the registry. I was looking for a key that would be consistent across versions. I have Win 2000 Pro and Win XP machines to test and this works on both of them.

    Dim strSection As String
    Dim strKey As String
    Dim strName As String
    Dim strDrive As String

    strSection = "HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrent Version"

    strKey = "ProgramFilesDir"
    strName = System.PrivateProfileString(FileName:="", Section:=strSection, Key:=strKey)

    strDrive = Left(strName, 1)
    strDrive = strDrive & ":templates"

    Options.DefaultFilePath(wdWorkgroupTemplatesPath) = strDrive

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: SystemDrive (Word 2002 SP2)

    Thanks for sharing, I'm sure the code snippet will come in handy one day.

    StuartR

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SystemDrive (Word 2002 SP2)

    My thanks too.

    I was thrown for a while by my environment showing "c:" as the value of %system%, but then I realised that you were modifying the value of strDrive after obtaining the drive letter.

    <pre>Public Function strPercentSystem() As String
    ' And then it dawned on me ... the registry. I was looking for a key that would be consistent across versions.
    ' I have Win 2000 Pro and Win XP machines to test and this works on both of them.
    'Darryl Hendricks
    'Systems Engineering

    Dim strSection As String
    Dim strKey As String
    Dim strName As String
    Dim strDrive As String

    strSection = "HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrent Version"

    strKey = "ProgramFilesDir"
    strName = System.PrivateProfileString(FileName:="", Section:=strSection, Key:=strKey)

    strDrive = Left(strName, 1) & ":"
    'strDrive = strDrive & ":templates"
    '
    'Options.DefaultFilePath(wdWorkgroupTemplatesPath) = strDrive
    strPercentSystem = strDrive
    End Function
    Sub TESTstrPercentSystem()
    MsgBox strPercentSystem
    End Sub</pre>


Posting Permissions

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