Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Sep 2007
    Posts
    45
    Thanks
    6
    Thanked 1 Time in 1 Post

    Declare a public variable while updating systems

    Hi, I hope someone can help me. I'm not sure if this can even be done, but we are in the process of upgrading all the systems in our office to Word 2010 and Windows 7. In the meantime, we have some systems running on Windows 7 and Word 2003 and some on Windows XP and Word 2003. The paths to the Startup folders where the Addins are stored are different in that the Windows 7 machines are referencing c:\program files (x86)\Microsoft Office\Office 11\Startup. I have a string publically declared that references Public Const STRSTARTUPPATH As String = "C:\Program Files\Microsoft Office\Office11\Startup\"

    Is there a way that I can somehow check to see if the system is on Windows 7 or Windows XP and then adjust the path on this string accordingly?

    Thanks so much.

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,176
    Thanks
    200
    Thanked 781 Times in 715 Posts
    Maverick,

    Here's code to determing the Windows Version.
    Code:
    Option Explicit
    
    Type OSVERSIONINFO   '  148 Bytes
            dwOSVersionInfoSize As Long
            dwMajorVersion As Long
            dwMinorVersion As Long
            dwBuildNumber As Long
            dwPlatformId As Long
            szCSDVersion As String * 128
    End Type
    
    Declare Function GetVersionEx& Lib "kernel32" _
    Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO)
    
    '                        +----------------------+                +----------+
    '------------------------| FindWindowsVersion() |----------------| 07/15/10 |
    '                        +----------------------+                +----------+
    
    Sub FindWindowsVersion()
    
       Dim tOSVer As OSVERSIONINFO
       Dim bNT    As Boolean    '*** Is this a version of NT? ***
       Dim zOsVer As String
       
       bNT = IIf(InStr(Application.OperatingSystem, "NT") = 0, False, True)
       
       tOSVer.dwOSVersionInfoSize = 148
       GetVersionEx& tOSVer
       
       With tOSVer
       
           If bNT Then
             Select Case .dwMajorVersion
                 Case 4: zOsVer = "Windows NT4"
                 Case 5: zOsVer = _
                      IIf(.dwMinorVersion = 1, "Windows XP", "Windows 2000")
                 Case 6: zOsVer = "Windows 7"
             End Select
             
           Else
           
             Select Case .dwMajorVersion
                 Case 4:
                     Select Case .dwMinorVersion
                           Case 0: zOsVer = "Windows 95"
                           Case 1: zOsVer = "Windows 98"
                           Case 9: zOsVer = "Windows ME"
                     End Select
                 Case 5: zOsVer = _
                      IIf(.dwMinorVersion = 1, "Windows XP", "Windows 2000")
             End Select
             
           End If
           
       End With      'tOSVer
       
       MsgBox "OS Version: " & zOsVer, vbOKOnly + vbInformation, _
              "Operating System Version"
              
    End Sub                  'FindWindowsVersion
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  3. The Following User Says Thank You to RetiredGeek For This Useful Post:

    maverik (2012-06-25)

  4. #3
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,894
    Thanks
    0
    Thanked 188 Times in 172 Posts
    On a PC with Office 2010, your startup path wouldn't be referencing a folder named 'Office 11' - which is for Word 2003. Accordingly, you're going to need something more sophisticated. Perhaps you could tell us what kinds of Addins you're concerned with and the context in which you're trying to retrieve their path.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,514
    Thanks
    3
    Thanked 143 Times in 136 Posts
    If you already have Word open then one line might be adequate.
    Application.StartupPath

    But as macropod asks, perhaps there is something trickier you are trying to do with your addins.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  6. The Following User Says Thank You to Andrew Lockton For This Useful Post:

    maverik (2012-06-25)

  7. #5
    Lounger
    Join Date
    Sep 2007
    Posts
    45
    Thanks
    6
    Thanked 1 Time in 1 Post
    Thank you so much. I tried using the coding for determining which version of Windows, but couldn't get it to save to a public variable. So thanks so much for the Application.StartupPath tip -- I had to replace that in all the macros themselves, but that was a simple search and replace.

    Everything is resolved now. Thanks again.

Posting Permissions

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