Hello,
I found this piece of code on the web and it's pretty descent. However it's just converting the first page of a series of three page documents.
Any ideas?
Thanks in advance!
I found this piece of code on the web and it's pretty descent. However it's just converting the first page of a series of three page documents.
Any ideas?
Thanks in advance!
VBA Code:
Option Explicit
Sub Word_To_PDF()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.DisplayStatusBar = True
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Settings")
Dim pdf_path As String
Dim word_path As String
pdf_path = sh.Range("E4").Value
word_path = sh.Range("E5").Value
Dim fso As New FileSystemObject
Dim fo As Folder
Dim f As File
Set fo = fso.GetFolder(pdf_path)
Dim wa As Object
Dim doc As Object
Set wa = CreateObject("word.application")
wa.Visible = True
Dim file_Count As Integer
For Each f In fo.Files
Application.StatusBar = "Converting - " & file_Count + 1 & "/" & fo.Files.Count
Set doc = wa.Documents.Open(f.Path)
doc.SaveAs2 (word_path & "\" & Replace(f.Name, ".pdf", ".docx"))
doc.Close False
file_Count = file_Count + 1
Next
wa.Quit
MsgBox "All PDF files have been converted in to word", vbInformation
Application.StatusBar = ""
End Sub