|
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 strTypeOfDocument(strFile As String) As String
' Procedure : cmd_TypeOfDocument
' Description: Determine what sort of document we have.
' Copyright: Chris Greaves Inc.
' Inputs: File name.
' Returns: STRING.
' Assumes: File exists, is of required minium length.
' Side Effects: None.
' Tested: By a call from the user.
Dim intFile As Integer
intFile = FreeFile
Open strFile For Binary As intFile
If boolChar(intFile, "WPC", 1) Then
strTypeOfDocument = "WPC" ' matches on 3 known criteria
ElseIf boolChar(intFile, "GIF", 0) Then
strTypeOfDocument = "GIF"
ElseIf boolHex(intFile, "D0CF11E0A1B11AE1", 0) Then
If boolHex(intFile, "FEFFFFFF", "3C") Then
strTypeOfDocument = "Excel"
Else
End If
ElseIf boolChar(intFile, "[ver]", 0) Then
strTypeOfDocument = "AmiPro"
ElseIf boolChar(intFile, "PK", 0) Then
strTypeOfDocument = "PKZip"
Else
strTypeOfDocument = strFile & " ; Unknown type"
End If
Close intFile
'Sub TESTstrTypeOfDocument()
' Dim strName As String ' Retain filename/extent from dialogue box.
' With Dialogs(wdDialogFileOpen)
' .Name = "*.*" ' Specifically interested in templates, since we're opeing VBE
' If .Display = -1 Then
' strName = .Name ' Grab the Name; user will have navigated to DefaultFilePath.
' MsgBox strTypeOfDocument(strName)
' Else
' End If
' End With
'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 |