Code: Select all
Function blnIsWordDocument(strFullName As String) As Boolean
' Return TRUE if we have a DOC or a DOT; that is, if we feel qualified to use Documents.Open on this file
Select Case UCase(Right(strFullName, 4))
Case ".DOC"
blnIsWordDocument = True
Case ".DOT"
blnIsWordDocument = True
Case Else
blnIsWordDocument = False
End Select
' FileType Property The constant msoFileTypeOfficeFiles includes all files with any of the following extensions: *.doc, *.xls, *.ppt, *.pps, *.obd, *.mdb, *.mpd, *.dot, *.xlt, *.pot, *.obt, *.htm, or *.html.
' CanOpen Property See AlsoApplies ToExampleSpecificsTrue if the specified file converter is designed to open files. Read-only Boolean.
' Open Method: ConfirmConversions Optional Variant. True to display the Convert File dialog box if the file isn't in Microsoft Word format.
' ConfirmConversions Property See AlsoApplies ToExampleSpecificsTrue if Word displays the Convert File dialog box before it opens or inserts a file that isn't a Word document or template. In the Convert File dialog box, the user chooses the format to convert the file from. Read/write Boolean.
End Function
The file extent is a guide, but the file name is just the name of a file, and it is not the same thing as the contents of a file. Which is why we rename our passwords document with an extent like “MRG” or “PNH”, but not “94s2wxbwwvhzfl”,right?
I used to test(attached) for WP51 files with
Code: Select all
If blnChar(intFile, "WPC", 1) Then
If blnHex(intFile, "01", 8) Then
If blnHex(intFile, "0A", 9) Then
blnWP51Doc = True ' matches on 3 known criteria
Given a few years I could probably cobble together code that uses some of the CanOpen Property[\b], Open Method[\b], or ConfirmConversions[\b], but interrogating whether or not a time-wasting dialogue box confronts the user is bad because I cannot then process a batch of files unattended (“Computers are good at doing boring and repetitive tasks).
Thanks
Chris