hi all,
i'm trying to write a macro that will save my already opened word doc as a PDF and closes the doc from my excel when i click a button. here is my code:
Private Sub CommandButton4_Click()
'name from cell in sheet
cName = Range("a1").Value
Dim appWD As Word.Application
Set appWD = GetObject(, "Word.Application")
appWD.Visible = True
Set wdDoc = appWD.Documents.Open("C:\Users\sesa460426\Documents\Quotes\Tool\QuickQuoteDoc.docx")
With wdDoc
.SaveAs ("C:\Users\sesa460426\Documents\Quotes") & cName & (".pdf")
.Close
End With
wdApp.Quit
End Sub
i keep getting run time error 91: object variable or with block variable not set.
it is saving it as a pdf but i can not open this pdf so i'm wondering if i have to use a different method to save it as pdf or is just cuz the runtime error in my code.
Thank you in advance
i'm trying to write a macro that will save my already opened word doc as a PDF and closes the doc from my excel when i click a button. here is my code:
Private Sub CommandButton4_Click()
'name from cell in sheet
cName = Range("a1").Value
Dim appWD As Word.Application
Set appWD = GetObject(, "Word.Application")
appWD.Visible = True
Set wdDoc = appWD.Documents.Open("C:\Users\sesa460426\Documents\Quotes\Tool\QuickQuoteDoc.docx")
With wdDoc
.SaveAs ("C:\Users\sesa460426\Documents\Quotes") & cName & (".pdf")
.Close
End With
wdApp.Quit
End Sub
i keep getting run time error 91: object variable or with block variable not set.
it is saving it as a pdf but i can not open this pdf so i'm wondering if i have to use a different method to save it as pdf or is just cuz the runtime error in my code.
Thank you in advance