Senin, 01 Oktober 2012

RES: [ExcelVBA] Selective PDF creation

 

You can try this one:

Sub CriaPDF()
'Versoes 2007 e acima - Excel 2007 and Later
Dim SvInput As String, myArr As Integer, Rng As Integer, nP As String
Dim MyArray() As Variant
'In This sheet put a listo f sheet's that you want to save in a pdf file

Sheets("Menu").Select
myArr = 0
Rng = 45
For x = 5 To Rng
If Cells(x, 28).Value = "X" Then
ReDim Preserve MyArray(NbPlan)
nP = Cells(x, 30)
MyArray(NbPlan) = nP
NbPlan = NbPlan + 1
End If
Next
SvInput = "C:\Temp\PROGR_PR" & "_" & Format(Date - 1, "dd-mm-yyyy") &
".pdf"
Sheets(MyArray).Select
If SvInput <> "False" Then
ActiveSheet.ExportAsFixedFormat xlTypePDF, SvInput, xlQualityStandard
Else
MsgBox "Path not Found"
End If
Sheets("Menu").Select
End Sub

Or you can use

Sub CriaPDF()
'Versoes 2007 e acima - Excel 2007 and Later
Dim SvInput As String, myArr As Integer, Rng As Integer, nP As String

SvInput = "C:\Temp\PROGR_PR" & "_" & Format(Date - 1, "dd-mm-yyyy") &
".pdf"
Sheets(Array("Summary", "Cost1", "Cost2", "Cost3", "Des1",
"Des2", "Des3")).Select

If SvInput <> "False" Then
ActiveSheet.ExportAsFixedFormat xlTypePDF, SvInput, xlQualityStandard
Else
MsgBox "Path not found"
End If
End Sub

De: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com] Em nome de
steven.eckley
Enviada em: segunda-feira, 1 de outubro de 2012 12:45
Para: ExcelVBA@yahoogroups.com
Assunto: [ExcelVBA] Selective PDF creation

I currently run this macro activated by a button to save my workbook as a
PDF file. The Macro works however I'd like to have only the first 7
worksheets included in the PDF creation all the other once should be
ignored.

The names of the worksheet tabs are always the same however other worksheets
change position into the first 7 and then be renamed to the standard name.
the name order is normally Summary, Cost1,Cost2,Cost3, Des1,Des2,Des3 and
ver.

In the save as fumction you have a option for selection however i do not
know how to replicate this in VBA to illiminate the human interaction

Sub Save2PDF()
'
' Save2PDF Macro
'
Dim WbP As String
Dim ProjectName As String
WbP = ActiveWorkbook.Path
ProjectName = Cells(5, 6)

'
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ProjectName &
"_Report", Quality:=xlQualityStandard, IncludeDocProperties:=True,
IgnorePrintAreas _
:=False, OpenAfterPublish:=True

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar