VBA macro creating pdf

B

Brad

The below works but I have two questions.

Question 1. How do I change this to access the sheets name?
Question 2. Can this code be condensed and still provide the same result?

Using Excel 2007....

Sub Updateforms()
Sheets(Array("PageFirst", "AAlt", "PageLast")).Select
Sheets("PageFirst").Activate
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"S:\PUBLIC\FundPerf\Performance flier\AA0508.pdf",
Quality:=xlQualityStandard _
, IncludeDocProperties:=True, IgnorePrintAreas:=False,
OpenAfterPublish:=False
End Sub
 
B

Brad

Ron,

If I'm reading your code correctly -
....ActiveWorkbook - does the entire workbook

....ActiveSheet - does one sheet

...ActiveSheet_Pages - does first X pages (1 to 2 in your example) from one
sheet

What I'm lookg for is one that will print only three sheets (or tabs) from a
workbook. Which is between your first and second macro...

I appreciate your help!
 
R

Ron de Bruin

Do a copy of the sheets first and then use the activeworkbook macro

Try this
Enter your sheet names in this code line
Sheets(Array("Sheet1", "Sheet3")).Copy


Sub RDB_PDF_Workbook()
Dim FilenameStr As String
Dim wb As Workbook

'create a new workbook with the sheets you want
Sheets(Array("Sheet1", "Sheet3")).Copy
Set wb = ActiveWorkbook

If Dir(Environ("commonprogramfiles") & "\Microsoft Shared\OFFICE" _
& Format(Val(Application.Version), "00") & "\EXP_PDF.DLL") <> "" Then

FilenameStr = Application.DefaultFilePath & "\" & _
Format(Now, "dd-mmm-yy h-mm-ss") & ".pdf"

wb.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=FilenameStr, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
MsgBox "You can find the PDF file here : " & FilenameStr

'close the file without saving
wb.Close False

Else
MsgBox "PDF add-in Not Installed"
End If
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


Brad said:
Ron,

If I'm reading your code correctly -
...ActiveWorkbook - does the entire workbook

...ActiveSheet - does one sheet

..ActiveSheet_Pages - does first X pages (1 to 2 in your example) from one
sheet

What I'm lookg for is one that will print only three sheets (or tabs) from a
workbook. Which is between your first and second macro...

I appreciate your help!
 
B

Brad

Ron
Restating my very first question - how do I change -

Sheets(Array("Sheet1", "Sheet3")).Copy
to (the below syntax is probably wrong)
Sheets(Array("shtCover", "shtValue", "shtFinal")).Copy

Where I control the sheet1's name as shtCover (in VBE)
and I control the sheet3 's name as shtFinal (in VBE)
 
R

Ron de Bruin

Hi Brad

Is shtCover the code name of the sheet in the VBE do you mean that ?

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


Brad said:
Ron
Restating my very first question - how do I change -

Sheets(Array("Sheet1", "Sheet3")).Copy
to (the below syntax is probably wrong)
Sheets(Array("shtCover", "shtValue", "shtFinal")).Copy

Where I control the sheet1's name as shtCover (in VBE)
and I control the sheet3 's name as shtFinal (in VBE)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top