Visual Basic (VB and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

 

Please read the DISCLAIMER.

Here is an INDEX to all the procedures.

You will probably need one copy of my GLOBAL DECLARATIONS.



Public Function blnNotVBA(strWordFile As String) As Boolean
''Re: Two related questions: SendKeys and version of Tem
''
''Howard Kaikow
''Thu 16-Nov-00, 06:52 am
''
''
'' Thanx.
''
'' I tried a variant given below.
''
'' In addition, I recalled that KB article Q224351 describes a DLL from MSFT that
'' allows access to the document summary properties. They include source code,
'' but I have not yet looked at it.
''
'' Here 's what I'm (ab)using in the interim. It does not check for non-Word files,
'' but I do not need to do that for this purpose.
''
    Const strMSWordDocument As String = "Microsoft Word Document"
    Const strMSWordDoc As String = "MSWordDoc"
    Const strWordDocument As String = "Word.Document.8"
    Dim intFileno As Integer
    Dim lngFileLength As Long
    Dim lngPos As Long
'Procs    Dim lngPrevPos As Long
    Dim strFileContent As String
'   Word97/SR2 fails if unsaved document with text; returns text if contents were deleted.
    intFileno = FreeFile
    Open strWordFile For Binary As intFileno
    lngFileLength = LOF(intFileno)
    strFileContent = Input(lngFileLength, intFileno)
    Close intFileno
    blnNotVBA = True
    lngPos = InStr(1, strFileContent, strMSWordDocument, vbBinaryCompare)
    If lngPos <> 0 Then
        lngPos = InStr(lngPos + 1, strFileContent, strMSWordDoc, vbBinaryCompare)
        If lngPos <> 0 Then
            lngPos = InStr(lngPos + 1, strFileContent, strWordDocument, vbBinaryCompare)
            If lngPos <> 0 Then
                blnNotVBA = False
            End If
        End If
    End If
'Sub testblnNotVBA()
'MsgBox blnNotVBA(ActiveDocument.FullName)
'End Sub
End Function

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Thursday, November 15, 2001

 

 

Hosted by www.Geocities.ws

1

Visual Basic (VB and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

 

Please read the DISCLAIMER.

Here is an INDEX to all the procedures.

You will probably need one copy of my GLOBAL DECLARATIONS.

Public Function blnNotVBA(strWordFile As String) As Boolean
''Re: Two related questions: SendKeys and version of Tem
''
''Howard Kaikow
''Thu 16-Nov-00, 06:52 am
''
''
'' Thanx.
''
'' I tried a variant given below.
''
'' In addition, I recalled that KB article Q224351 describes a DLL from MSFT that
'' allows access to the document summary properties. They include source code,
'' but I have not yet looked at it.
''
'' Here 's what I'm (ab)using in the interim. It does not check for non-Word files,
'' but I do not need to do that for this purpose.
''
    Const strMSWordDocument As String = "Microsoft Word Document"
    Const strMSWordDoc As String = "MSWordDoc"
    Const strWordDocument As String = "Word.Document.8"
    Dim intFileno As Integer
    Dim lngFileLength As Long
    Dim lngPos As Long
'Procs    Dim lngPrevPos As Long
    Dim strFileContent As String
'   Word97/SR2 fails if unsaved document with text; returns text if contents were deleted.
    intFileno = FreeFile
    Open strWordFile For Binary As intFileno
    lngFileLength = LOF(intFileno)
    strFileContent = Input(lngFileLength, intFileno)
    Close intFileno
    blnNotVBA = True
    lngPos = InStr(1, strFileContent, strMSWordDocument, vbBinaryCompare)
    If lngPos <> 0 Then
        lngPos = InStr(lngPos + 1, strFileContent, strMSWordDoc, vbBinaryCompare)
        If lngPos <> 0 Then
            lngPos = InStr(lngPos + 1, strFileContent, strWordDocument, vbBinaryCompare)
            If lngPos <> 0 Then
                blnNotVBA = False
            End If
        End If
    End If
'Sub testblnNotVBA()
'MsgBox blnNotVBA(ActiveDocument.FullName)
'End Sub
End Function

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Thursday, November 15, 2001

 

 

Hosted by www.Geocities.ws

1