Solved I want to use a macro to save an Excel worksheet to a .pdf.

August 5, 2012 at 01:34:39
Specs: Windows 7
I have a worksheet that I want to concurrently print a hard copy and save to a .pdf file in a folder on my computer. The worksheet that I want to print and save to .pdf is not the active worksheet.

I would like for the worksheet to be saved to .pdf with a unique file name. The worksheets saved as .pdfs will be archived, and it's important that they are not written over.

Could someone help me with the VBA code to do so?

Thank you for any help you can be.

Sincerely,

Mark1011


See More: I want to use a macro to save an Excel worksheet to a .pdf.

Report •


#1
Report •

#2
August 10, 2012 at 00:44:18
This was of little help to me. To be honest, it's so far over my head that I don't understand it at all.

I tried pasting the code into a VBA module, but I kept getting the MsgBox with all the possible problems. I have Excel 2007 with SP3 installed, but it doesn't seem to recognize the .pdf add-in. I downloaded and installed the add-in from the link in Mr. DeBruin's web page, but with the same result.

I'm a novice, and if it is possible to get a little bit of more remedial help, I'd sure be grateful.

Thank you for any time you can spend.

Sincerely,

Mark1011


Report •

#3
August 10, 2012 at 02:13:11
✔ Best Answer
Hi Mark,

Try this, iv tested it and it works great.

Dim nFileName As String

Sub CreatePDF()

 My_Path = "C:\"

 nFileName = "Test"
 
 Application.DisplayAlerts = False
 ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
 My_Path & "\" & nFileName & ".PDF", Quality _
 :=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
 OpenAfterPublish:=False
 Application.DisplayAlerts = True


 ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
 My_Path & "\" & nFileName & ".PDF", Quality _
 :=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
 OpenAfterPublish:=False
 
 
End Sub


Report •

Related Solutions

#4
August 10, 2012 at 22:03:24
Dear AlwaysWillingToLearn,

Works perfect! Thanks soooo much!

Sincerely,

Mark


Report •


Ask Question