Save as PDF Printing

vbanovice2701

New Member
Joined
Jun 23, 2022
Messages
2
Office Version
  1. 365
Platform
  1. MacOS
Hi,
I am trying to save a file as a PDF based on a particular cell value. The below macro appears to work once only, then it seems to want to print. Can someone please help, I am going round in circles with different coding

Sub SavePDF()
'
' SavePDF Macro

Dim file As String

Sheets("XXX").Activate

file = Cells(16, 13).Text


ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
FileName:="/office/XXX/" & file

End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
I see no reason why it should want to print unless this code is unexpectedly calling some other code, or perhaps that is the behaviour when your separators are backwards ( / vs \ ). I'm surprised that works. Not sure what you mean that it only works once. That should be the case, unless you're changing cell reference or value in between calls. By that I mean if you try to use the same cell value for multiple calls (and assuming this makes the entire file path the same each time) you should raise an error.
 
Upvote 0
I see no reason why it should want to print unless this code is unexpectedly calling some other code, or perhaps that is the behaviour when your separators are backwards ( / vs \ ). I'm surprised that works. Not sure what you mean that it only works once. That should be the case, unless you're changing cell reference or value in between calls. By that I mean if you try to use the same cell value for multiple calls (and assuming this makes the entire file path the same each time) you should raise an error.
Thanks for the reply. It runs perfectively fine the first time you run the macro. The cell reference doesn't change, just the value in it (which is pasted values from another cell which is formula)
 
Upvote 0

Forum statistics

Threads
1,214,968
Messages
6,122,509
Members
449,089
Latest member
RandomExceller01

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