jazzyt2u
10-16-2008, 03:08 PM
Hi,
I am trying to automate the process to print word documents to pdf. The coding below works to a point. It's making me click the Save. I don't want to have to babysit this process. Also after I select save I get warnings about margins being outside of the printable range this time making me select yes. These warnings don't appear if I do it manually.
Please help : pray2:
Sub ConvertPdf()
Dim MyFolder As String
Dim oWord As Object
Dim oDoc As Object
Dim NextFile As String
Dim MyFile As String
Set oWord = CreateObject("Word.Application") 'Create an instance of word
MyFolder = InputBox("Please enter or copy and paste the folder path that contains the files for this project." & vbNewLine & _
vbNewLine & "EX: H:\TashaA\Test2\" & vbNewLine & vbNewLine & "Don't forget the last ' \ '")
If Right(MyFolder, 1) <> "\" Then
Do Until Right(MyFolder, 1) = "\"
MyFolder = InputBox("You didn't enter the last '\'." & vbNewLine & vbNewLine & "Please re-enter your folder path EX: H:\TashaA\Test2\")
Loop
End If
NextFile = Dir(MyFolder & "*.doc")
Do While NextFile <> ""
Set oDoc = oWord.Documents.Open(MyFolder & NextFile) 'Open word file
oWord.Visible = True
oWord.ActivePrinter = "Acrobat PDFWriter"
oWord.ActiveDocument.PrintOut
oDoc.Close
NextFile = Dir
Loop
End Sub
Aussiebear: jazzyt2u I have moved this thread from Excel so you can get the assistance you were seeking.
I am trying to automate the process to print word documents to pdf. The coding below works to a point. It's making me click the Save. I don't want to have to babysit this process. Also after I select save I get warnings about margins being outside of the printable range this time making me select yes. These warnings don't appear if I do it manually.
Please help : pray2:
Sub ConvertPdf()
Dim MyFolder As String
Dim oWord As Object
Dim oDoc As Object
Dim NextFile As String
Dim MyFile As String
Set oWord = CreateObject("Word.Application") 'Create an instance of word
MyFolder = InputBox("Please enter or copy and paste the folder path that contains the files for this project." & vbNewLine & _
vbNewLine & "EX: H:\TashaA\Test2\" & vbNewLine & vbNewLine & "Don't forget the last ' \ '")
If Right(MyFolder, 1) <> "\" Then
Do Until Right(MyFolder, 1) = "\"
MyFolder = InputBox("You didn't enter the last '\'." & vbNewLine & vbNewLine & "Please re-enter your folder path EX: H:\TashaA\Test2\")
Loop
End If
NextFile = Dir(MyFolder & "*.doc")
Do While NextFile <> ""
Set oDoc = oWord.Documents.Open(MyFolder & NextFile) 'Open word file
oWord.Visible = True
oWord.ActivePrinter = "Acrobat PDFWriter"
oWord.ActiveDocument.PrintOut
oDoc.Close
NextFile = Dir
Loop
End Sub
Aussiebear: jazzyt2u I have moved this thread from Excel so you can get the assistance you were seeking.