![]() |
#1
|
|||
|
|||
![]()
I have recently realised that a large number of PDFs can be opened within Word on Windows retaining the formatting and the footnotes. Accordingly, I thought I'd try it on a collection of files I have. Problem is, I cannot seem to loop through the PDF files in a folder and saving them as .docx.
I have managed to get it to open the files, but not to save them as .docx. Ideally, I would also need some insight as to how to bypass error messages and proceed to the next file when that happens, but I have not been able to find a way to do that either. I must have made some major mistakes on the way, but below is what I have tried. Many thanks! Code:
Sub UpdateDocuments() Application.ScreenUpdating = False Dim strFolder As String, strFile As String, wdDoc As Document strFolder = GetFolder If strFolder = "" Then Exit Sub strFile = Dir(strFolder & "\*.pdf", vbNormal) While strFile <> "" Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False) ActiveDocument.SaveAs FileName:=DocName, FileFormat:=wdFormatPDF ActiveWindow.Close SaveChanges = False .Close SaveChanges:=True End With strFile = Dir() Wend 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 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Plokimu77 | Word VBA | 4 | 06-05-2016 04:41 PM |
![]() |
joewoods | Word VBA | 13 | 05-16-2016 06:29 PM |
Saving PPT as a looping video | Frank Bugek | PowerPoint | 0 | 08-23-2015 08:04 PM |
![]() |
Gweilo | Word | 3 | 02-16-2015 03:38 PM |
![]() |
donkrafft | Word | 12 | 02-05-2010 05:15 PM |