VBA Macro to auto save PDF files (CutePDF)

klutzz

New Member
Joined
Oct 11, 2015
Messages
4
Hi, I am trying to automate my PDF print outs by using the record macro function.
However, the recording function is not able to capture my file name and path where I need to save the new PDFs.

The current codes are as per below, can anyone help to advise how I can automate the whole process?

Sub Macro1()
Selection.AutoFilter Field:=2, Criteria1:="=China", Operator:=xlOr, _
Criteria2:="=Hong Kong"
Application.ActivePrinter = "CutePDF Writer on CPW2:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"CutePDF Writer on CPW2:", Collate:=True
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
thats because this function doesn't work for me.

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Range("A1").Value _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True


I keep getting "object doesn't support this property or method"
 
Upvote 0
Perhaps, then, you should establish that whatever you have in A1 is actually valid for use as a filename.
There is nothing fundamentally wrong with the code, though it would be better to use something like:
Code:
With ActiveSheet
  .ExportAsFixedFormat Type:=xlTypePDF, Filename:=.Range("A1").Value, _
    Quality:=xlQualityStandard, IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, OpenAfterPublish:=True
End With
 
Upvote 0
Upvote 0
The .ExportAsFixedFormat method works without the need for any third-party app, as it uses Excel's built-in functionality.

FWIW, the code I posted worked just fine in my testing. If it's not working for you, you might try repairing the Office installation (via Start > Windows Control Panel > Programs > Programs & Features > Microsoft Office (version) > Change>Repair).
 
Upvote 0

Forum statistics

Threads
1,216,025
Messages
6,128,341
Members
449,443
Latest member
Chrissy_M

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