amb2301
New member
- Joined
- May 18, 2020
- Messages
- 15
- Reaction score
- 0
- Points
- 0
- Excel Version(s)
- excel 2013
Hi Friends,
i have a task to convert lot of word files to PDF files , i found some code which does the convertion correctly but its not happening for the Subfolders inside the folder
coud someone helpme to fix it.
i have a task to convert lot of word files to PDF files , i found some code which does the convertion correctly but its not happening for the Subfolders inside the folder
coud someone helpme to fix it.
HTML:
Option Explicit
Sub Word_To_PDF()
Application.ScreenUpdating = False
Application.DisplayStatusBar = True
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Sheet1")
Dim fso As New FileSystemObject
Dim fo As Folder
Dim f As File
Dim wb As Workbook
Dim n As Integer
Dim wordapp As New Word.Application
Dim worddoc As Word.Document
Set fo = fso.GetFolder(sh.Range("E13").Value)
For Each f In fo.Files
n = n + 1
Application.StatusBar = "Processing..." & n & "/" & fo.Files.Count
Set worddoc = wordapp.Documents.Open(f.Path)
worddoc.ExportAsFixedFormat sh.Range("E14").Value & Application.PathSeparator & VBA.Replace(f.Name, ".docx", ".pdf"), wdExportFormatPDF
worddoc.Close False
Next
Application.StatusBar = ""
MsgBox "Process Completed"
End Sub