Identify an Word/Excel file without the doc/xls extension
You cud try something like:
From Word VBA
Dim o As Object, fName As String
With Application.FileSearch
.NewSearch
.LookIn = "c:\temp\test"
.FileName = "*.*"
.Execute
For x = 1 To .FoundFiles.Count
fName = .FoundFiles(x)
Set o = GetObject(fName)
On Error GoTo ErrUnkown
Debug.Print fName, o.Parent
Next
End With
Set o = Nothing
Exit Sub
ErrUnkown:
Debug.Print fName, "Unkown"
Resume Next
Resulting in following lines in the Immediate Window
C:\temp\test\NoExtensionWD Microsoft Word
C:\temp\test\NoExtensionXL Microsoft Excel
Note: files have no extension.
Krgrds,
Perry
"Rui Oliveira" wrote in message
...
Hi,
How can I know if a file is an Word/Excel file, when the
file does not have the doc/xls extension?
I have a folder with a lot of files and all them without
extension (xls, doc, txt, .). How can I know witch these
files are Word or Excel files?
Thanks,
Rui
|