Я хочу экспортировать 4 таблицы (НЕ врезанные) и 1 лист в один файл PDF.У меня также есть другие листы в книге, которые я не хочу экспортировать в PDF, поэтому я не могу экспортировать всю книгу.
Я могу экспортировать диаграммы в PDF и листы в PDF, но не могу найти способ экспортировать оба типа в один и тот же PDF.
Это код, который у меня естьдо сих пор:
Sub SaveAsPDF()
Dim wsA As Worksheet
Dim wsB As Worksheet
Dim wbA As Workbook
Dim strTime As String
Dim StrName As String
Dim strPath As String
Dim strFile As String
Dim strPathFile As String
Dim myFile As Variant
Dim i As Integer
Dim NameArray As Variant
Dim NameString As String
Dim varChart As Chart
On Error GoTo errHandler
Set wbA = ActiveWorkbook
strTime = Format(Now(), "ddmmyyyy")
wbA.Sheets("Setting Calculations").Select
wbA.Charts(Array("ToC Plot - Fault Scenario 1", "ToC Plot - Fault Scenario
2", "ToC Plot - Fault Scenario 3", "ToC Plot - Fault Scenario 4")).Select
'get active workbook folder, if saved
strPath = wbA.Path
If strPath = "" Then
strPath = Application.DefaultFilePath
End If
strPath = strPath & "\"
'Sets name of file
StrName = "Setting Calculations & Plots"
'create default name for savng file
strFile = StrName & "_" & strTime & ".pdf"
strPathFile = strPath & strFile
'use can enter name and
' select folder for file
myFile = Application.GetSaveAsFilename _
(InitialFileName:=strPathFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
'export to PDF if a folder was selected
If myFile <> "False" Then
'This will only print the sheet, if I write ActiveChart it prints the charts
but i cant find a way to print both
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=myFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End If
exitHandler:
Exit Sub
errHandler:
MsgBox "Could not create PDF file"
Resume exitHandler
End Sub