View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.misc
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default VBA macro creating pdf

Hi Brad

You are welcome

I also add a example to the pdf page
http://www.rondebruin.nl/pdf.htm

--

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


"Brad" wrote in message ...
Thank you!!
--
Wag more, bark less


"Ron de Bruin" wrote:

Hi Brad

Use this then in the array

Sheets(Array(shtCover.Name, shtValue.Name, shtFinal.Name)).Copy

--

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


"Brad" wrote in message ...
Yes!!
--
Wag more, bark less


"Ron de Bruin" wrote:

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" wrote in message ...
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)

"Ron de Bruin" wrote:

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" wrote in message ...
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!
--
Wag more, bark less


"Ron de Bruin" wrote:

Hi Brad

See if you find your answer on this page
http://www.rondebruin.nl/pdf.htm

--

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


"Brad" wrote in message ...
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


--
Wag more, bark less