Little Nudge needed to get me home free

ChuckDrago

Active Member
Joined
Sep 7, 2007
Messages
470
Office Version
  1. 2010
Platform
  1. Windows
Hi everyone,

I am trying to get a Word document to open (so that it updates its date) and then save it to a designated folder as a pdf. I tried to adapt a great macro I got in this forum but to no avail. Here is the code, thus far:
<code/>Sub SubTest()
Dim Pth As String, Fname As String
Pth = "C:\Latex Free Holder"
Fname = "Cover Letter"
Dim objWord
Dim objDoc
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("L:\Intranet Elements\Latex Free Masters\Latex Free Cover Letter.docx")
objWord.Visible = True
objWord.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
Pth & Fname, Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
End Sub</code>
The error occurs in the export statement. I tried ActiveDocument, objWord and objDoc as starters, but nothing seems to work. Errors go from Object required to Method not supported.
Any suggestions will be much appreciated, as always,
Chuck
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
What's Up Chuck (sorry for the dad joke)

Try:

Code:
Sub Test()
Dim Pth As String, Fname As String
Pth = "C:\Latex Free Holder"[B][COLOR=#0000ff] & "\"[/COLOR][/B]
Fname = "Cover Letter"


Dim objWord
Dim objDoc
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("L:\Intranet Elements\Latex Free Masters\Latex Free Cover Letter.docx")
objWord.Visible = True
objWord.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    Pth & Fname[COLOR=#0000ff][B] & ".pdf"[/B][/COLOR], Quality:=xlQualityStandard, IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, OpenAfterPublish:=False
End Sub
 
Upvote 0
What's Up Chuck (sorry for the dad joke)

Try:

Code:
Sub Test()
Dim Pth As String, Fname As String
Pth = "C:\Latex Free Holder"[B][COLOR=#0000ff] & "\"[/COLOR][/B]
Fname = "Cover Letter"


Dim objWord
Dim objDoc
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("L:\Intranet Elements\Latex Free Masters\Latex Free Cover Letter.docx")
objWord.Visible = True
objWord.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    Pth & Fname[COLOR=#0000ff][B] & ".pdf"[/B][/COLOR], Quality:=xlQualityStandard, IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, OpenAfterPublish:=False
End Sub

No good, sorry.
 
Upvote 0
Sorry, I didn't test fully since I don't have an "L drive".

ExportAsFixedFormat is a method of Word.Document (objDoc), not Word.Application (objWord). So adjust your last line to this:
Code:
objDoc.ExportAsFixedFormat OutputFileName:=Pth & Fname & ".pdf", _
    ExportFormat:=wdExportFormatPDF
 
Upvote 0
Sorry, I didn't test fully since I don't have an "L drive".

ExportAsFixedFormat is a method of Word.Document (objDoc), not Word.Application (objWord). So adjust your last line to this:
Code:
objDoc.ExportAsFixedFormat OutputFileName:=Pth & Fname & ".pdf", _
    ExportFormat:=wdExportFormatPDF

No cigar... It reports Error 5 (Invalid procedure, call or argument)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top