Try the following macro:
Code:
Sub GeneratePDFs()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, strDocNm As String, wdDoc As Document, i As Long, ArrExt, StrExt As String
ArrExt = Array(".bil", ".txt")
strDocNm = ActiveDocument.FullName
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFolder = strFolder & "\"
For i = 0 To 1
StrExt = ArrExt(i)
strFile = Dir(strFolder & "*" & StrExt, vbNormal)
While strFile <> ""
Set wdDoc = Documents.Open(FileName:=strFolder & strFile, ConfirmConversions:=False, _
ReadOnly:=True, AddToRecentFiles:=False, Visible:=False)
With wdDoc
.SaveAs FileName:=strFolder & Split(strFile, StrExt, , vbTextCompare)(0) & ".pdf", _
FileFormat:=wdFormatPDF, AddToRecentFiles:=False
.Close SaveChanges:=False
End With
strFile = Dir()
Wend
Next
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
Simply select the folder to process and the macro should convert all .BIL and .TXT files in that folder to PDFs.