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 boolWP51Doc(strFile As String) As Boolean
' Procedure :   boolWP51Doc
' Description:  Test if a file is a WordPerfect 5.1 (DOS) document file.
' Copyright:    Chris Greaves Inc.
' Inputs:       File name.
' Returns:      TRUE if test is successful.
' Assumes:      File exists, is of required minium length.
' Side Effects: None.
' Tested:       By the calls shown below.
    boolWP51Doc = False ' default is failure
    Dim intFile As Integer
    intFile = FreeFile
    Open strFile For Binary As intFile
    If boolChar(intFile, "WPC", 1) Then
        If boolHex(intFile, "01", 8) Then
            If boolHex(intFile, "0A", 9) Then
                boolWP51Doc = True ' matches on 3 known criteria
            Else
                MsgBox "not a doc"
            End If
        Else
            MsgBox "not a wp product"
        End If
    Else
        MsgBox "not a WPC header"
    End If
    Close intFile
'Sub TESTboolWP51Doc()
'MsgBox boolWP51Doc("i:\greaves\training\wordpr~1\wp51\Maths.w51") ' true
'MsgBox boolWP51Doc("i:\greaves\training\wordpr~1\wp51\Alto.wpm") ' false
'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 boolWP51Doc(strFile As String) As Boolean
' Procedure :   boolWP51Doc
' Description:  Test if a file is a WordPerfect 5.1 (DOS) document file.
' Copyright:    Chris Greaves Inc.
' Inputs:       File name.
' Returns:      TRUE if test is successful.
' Assumes:      File exists, is of required minium length.
' Side Effects: None.
' Tested:       By the calls shown below.
    boolWP51Doc = False ' default is failure
    Dim intFile As Integer
    intFile = FreeFile
    Open strFile For Binary As intFile
    If boolChar(intFile, "WPC", 1) Then
        If boolHex(intFile, "01", 8) Then
            If boolHex(intFile, "0A", 9) Then
                boolWP51Doc = True ' matches on 3 known criteria
            Else
                MsgBox "not a doc"
            End If
        Else
            MsgBox "not a wp product"
        End If
    Else
        MsgBox "not a WPC header"
    End If
    Close intFile
'Sub TESTboolWP51Doc()
'MsgBox boolWP51Doc("i:\greaves\training\wordpr~1\wp51\Maths.w51") ' true
'MsgBox boolWP51Doc("i:\greaves\training\wordpr~1\wp51\Alto.wpm") ' false
'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