How to include excel files?
Hello everyone. Hope you are well. I have pieced together the following code but I need to include the possibility that an excel file type may be selected. Any guidance appreciated.
Code:
Sub DeleteTypesOfFiles()
'Kilroy
Dim strFilename As String
Dim strDocName As String
Dim strPath As String
Dim oDoc As Document
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.Title = "Select folder and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" Then strPath = strPath + "\"
End With
If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
If Left(strPath, 1) = Chr(34) Then
strPath = Mid(strPath, 2, Len(strPath) - 2)
End If
strFilename = Dir$(strPath & InputBox("File type? aterisk.type"))
While Len(strFilename) <> 0
Set oDoc = Documents.Open(strPath & strFilename)
MyFile = ActiveDocument.path & "\" & ActiveDocument.Name
ActiveDocument.Close (wdDoNotSaveChanges)
Kill MyFile
strFilename = Dir$()
Wend
End Sub