SaifnJeans
New Member
- Joined
- Jun 5, 2022
- Messages
- 2
- Office Version
- 2019
- Platform
- Windows
Hi Respected All Excel Experts, I need to convert Excel Sheet to PDF and then that PDF to Word. I have somehow managed to make and get following code through which my PDF file is getting saved in specific Folder with Specific name and even opening Word File But getting error in last 2 lines of the Code. Any help in this regard will really be appreciated;
Sub SaveAspdf()
Dim Path As String
Dim Deal As String
Dim Agent As String
Dim DocType As String
Dim dt_issue As Date
Dim FName As String
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Document")
Dim fso As New FileSystemObject
Dim fo As Folder
Dim f As File
Dim wa As New Word.Application
Dim doc As Word.Document
wa.Visible = True
Dim pdf_path As String
Dim word_path As String
Path = Range("D4")
Deal = Range("C3")
Agent = Range("C4")
DocType = Range("C5")
dt_issue = Range("B6")
FName = Deal & " " & Agent & " " & DocType
Sheets("Document").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Path & FName, OpenAfterPublish:=False
pdf_path = sh.Range("D4").Value
word_path = sh.Range("D5").Value
Set doc = wa.Documents.Open(f.Path)
doc.SaveAs2 (word_path & "\" & Replace(f.Name, ".pdf", ".docx"))
Sub SaveAspdf()
Dim Path As String
Dim Deal As String
Dim Agent As String
Dim DocType As String
Dim dt_issue As Date
Dim FName As String
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Document")
Dim fso As New FileSystemObject
Dim fo As Folder
Dim f As File
Dim wa As New Word.Application
Dim doc As Word.Document
wa.Visible = True
Dim pdf_path As String
Dim word_path As String
Path = Range("D4")
Deal = Range("C3")
Agent = Range("C4")
DocType = Range("C5")
dt_issue = Range("B6")
FName = Deal & " " & Agent & " " & DocType
Sheets("Document").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Path & FName, OpenAfterPublish:=False
pdf_path = sh.Range("D4").Value
word_path = sh.Range("D5").Value
Set doc = wa.Documents.Open(f.Path)
doc.SaveAs2 (word_path & "\" & Replace(f.Name, ".pdf", ".docx"))