Save a pdf to the desktop with a filename as a cell reference
Hi
Try to use a variable to build the file name string before the
ExportAsFixedFormat statement.
Dim PDFFileName As String
PDFFileName = _
"C:\Documents and Settings\all users\Desktop/" _
& Range("A18").Value & ".pdf"
ActiveSheet.ExportAsFixedFormat _
Type:=x1typepdf, _
Filename:=PDFFileName, _
Openafterpublish:=False
Hopes this helps.
Regards,
Per
On 13 Nov., 22:50, Beric Dondarrion <Beric
wrote:
I'm currently working on a macro that is on a network (i.e. deals with the
Ne0x issue"), saves a pdf of a certain print area to the desktop, bypasses
the "Save as" box of the non MS pdf writer (Doro PDF Writer), and names the
file based on a cell reference.
Whew!
I've got everything working except the filename = cell reference
Here's what is currently working if I wanted to just pick an arbitrary
filename:
ActiveSheet.ExportAsFixedFormat _
* * * * Type:=x1typepdf, _
* * * * Filename:="C:\Documents and Settings\all users\Desktop/test.pdf", _
* * * * Openafterpublish:=False
I'm aware of the forward slash. *For some reason, that's working. *Anyway,
this is what I thought would work:
ActiveSheet.ExportAsFixedFormat _
* * * * Type:=x1typepdf, _
* * * * Filename:="C:\Documents and Settings\all users\Desktop/" _ *
* * * * & Range("A18").Value & ".pdf", _
* * * * Openafterpublish:=False
But it's not. *I get a run time error and a "File not Saved" notice. *Btw,
the line break in the filepath is only in this post because the message box
isn't wide enough.
Any help would be great.
|