I did search the forum a bit first, but couldn't find an answer...
I want to create a macro that will select text in a certian cell, then use that text as part of a name when it publishes the sheet to PDF. I used the Macro recorder to create the code below.
Each month I will update the contents of cell B6 (201102 = February 2011, 201103 = March 2011, etc.)
I want to save the analysis on Sheet "18CFA" each month as a PDF, and I want the file name to begin with the 6-digit month identifier ("201103 - Line 18 Analysis.pdf" in this example).
In the current macro, I go to the number in B6, copy it, then go to the sheet I want to save and click the "Save As PDF or XPS" button. I then Paste what was copied from B6 (in this case, "201103", then type the rest of the name and click Publish.
The macro currently does two things wrong. First, when it's finished, the contents of cell B6 are always "201103," and second, obviously, it's not using what I type into B6 as the file name.
Anyway... here's the code:
Sub PrintPDF()
'
' PrintPDF Macro
'
'
Range("B6").Select
ActiveCell.FormulaR1C1 = "201103"
Range("A1").Select
Sheets("18FCA").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Documents and Settings\mstuenke\Desktop\201103 - Line 18 Analysis.pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
End Sub
I want to create a macro that will select text in a certian cell, then use that text as part of a name when it publishes the sheet to PDF. I used the Macro recorder to create the code below.
Each month I will update the contents of cell B6 (201102 = February 2011, 201103 = March 2011, etc.)
I want to save the analysis on Sheet "18CFA" each month as a PDF, and I want the file name to begin with the 6-digit month identifier ("201103 - Line 18 Analysis.pdf" in this example).
In the current macro, I go to the number in B6, copy it, then go to the sheet I want to save and click the "Save As PDF or XPS" button. I then Paste what was copied from B6 (in this case, "201103", then type the rest of the name and click Publish.
The macro currently does two things wrong. First, when it's finished, the contents of cell B6 are always "201103," and second, obviously, it's not using what I type into B6 as the file name.
Anyway... here's the code:
Sub PrintPDF()
'
' PrintPDF Macro
'
'
Range("B6").Select
ActiveCell.FormulaR1C1 = "201103"
Range("A1").Select
Sheets("18FCA").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Documents and Settings\mstuenke\Desktop\201103 - Line 18 Analysis.pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
End Sub