Results 1 to 4 of 4

Thread: Word versions from VB

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 1999
    Location
    Littlehampton, W Sussex GB
    Posts
    203

    Word versions from VB

    I am launching Word with a document containing information from my database, from a VB6 program. This is run on a network where some users now have a new version of Word(Office 2000).
    How can I cope with these different versions in my code? I am referencing the Word object library.

  2. #2
    FNARR
    Guest
    Don't use the reference to the Word Library, use CreateObject or GetObject.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    I've used both Word97 and Word2000 from VB code, and programmatically, I've seen no difference. Code that I wrote before Office2000 was released still works. Are you having issues?

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Here is some code that you can use to determine what version of Word you are running. It would be helpful for you to have both WinWord.Exe for Word97 and WinWord.Exe for Office2000
    VB Code:
    1. Private Declare Function GetFileVersionInfo Lib "Version.dll" Alias "GetFileVersionInfoA" (ByVal lptstrFilename As String, ByVal dwhandle As Long, ByVal dwlen As Long, lpData As Any) As Long
    2. Private Declare Function GetFileVersionInfoSize Lib "Version.dll" Alias "GetFileVersionInfoSizeA" (ByVal lptstrFilename As String, lpdwHandle As Long) As Long
    3. Private Declare Function VerQueryValue Lib "Version.dll" Alias "VerQueryValueA" (pBlock As Any, ByVal lpSubBlock As String, lplpBuffer As Any, puLen As Long) As Long
    4. Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, ByVal Source As Long, ByVal length As Long)
    5.  
    6. Private Type VS_FIXEDFILEINFO
    7.    dwSignature As Long
    8.    dwStrucVersionl As Integer     '  e.g. = &h0000 = 0
    9.    dwStrucVersionh As Integer     '  e.g. = &h0042 = .42
    10.    dwFileVersionMSl As Integer    '  e.g. = &h0003 = 3
    11.    dwFileVersionMSh As Integer    '  e.g. = &h0075 = .75
    12.    dwFileVersionLSl As Integer    '  e.g. = &h0000 = 0
    13.    dwFileVersionLSh As Integer    '  e.g. = &h0031 = .31
    14.    dwProductVersionMSl As Integer '  e.g. = &h0003 = 3
    15.    dwProductVersionMSh As Integer '  e.g. = &h0010 = .1
    16.    dwProductVersionLSl As Integer '  e.g. = &h0000 = 0
    17.    dwProductVersionLSh As Integer '  e.g. = &h0031 = .31
    18.    dwFileFlagsMask As Long        '  = &h3F for version "0.42"
    19.    dwFileFlags As Long            '  e.g. VFF_DEBUG Or VFF_PRERELEASE
    20.    dwFileOS As Long               '  e.g. VOS_DOS_WINDOWS16
    21.    dwFileType As Long             '  e.g. VFT_DRIVER
    22.    dwFileSubtype As Long          '  e.g. VFT2_DRV_KEYBOARD
    23.    dwFileDateMS As Long           '  e.g. 0
    24.    dwFileDateLS As Long           '  e.g. 0
    25. End Type
    26.  
    27. Private Sub GetVerInfo()
    28.    'modified from the example in the API Viewer from [url]http://www.allapi.net/[/url]
    29.    Dim rc As Long
    30.    Dim lDummy As Long
    31.    Dim sBuffer() As Byte
    32.    Dim lBufferLen As Long
    33.    Dim lVerPointer As Long
    34.    Dim udtVerBuffer As VS_FIXEDFILEINFO
    35.    Dim lVerbufferLen As Long
    36.  
    37.    'plug WinWord.Exe and its path into the variable FullFileName
    38.    lBufferLen = GetFileVersionInfoSize(FullFileName, lDummy)
    39.    If lBufferLen < 1 Then
    40.       MsgBox "No Version Info available!"
    41.       Exit Sub
    42.    End If
    43.  
    44.    '**** Store info to udtVerBuffer struct ****
    45.    ReDim sBuffer(lBufferLen)
    46.    rc = GetFileVersionInfo(FullFileName, 0&, lBufferLen, sBuffer(0))
    47.    rc = VerQueryValue(sBuffer(0), "\", lVerPointer, lVerbufferLen)
    48.    MoveMemory udtVerBuffer, lVerPointer, Len(udtVerBuffer)
    49.    '**** Determine File Version number ****
    50.    FileVer = Format$(udtVerBuffer.dwFileVersionMSh) & "." & Format$(udtVerBuffer.dwFileVersionMSl) & "." & Format$(udtVerBuffer.dwFileVersionLSh) & "." & Format$(udtVerBuffer.dwFileVersionLSl)
    51.  
    52. End Sub

Posting Permissions

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



Click Here to Expand Forum to Full Width