View Single Post
 
Old 04-13-2018, 03:38 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote