vbscript 使用文件对话框将工作簿导出为PDF

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript 使用文件对话框将工作簿导出为PDF相关的知识,希望对你有一定的参考价值。

Sub PDFWorkbook()
    Dim strSheets() As String
    Dim strfile As String
    Dim sh As Worksheet
    Dim icount As Integer
    Dim myfile As Variant
    Dim startingPage As Integer
    
    ' Save Chart Sheet names to an Array
    For Each sh In ActiveWorkbook.Worksheets
    If sh.Visible = xlSheetVisible Then
        ReDim Preserve strSheets(icount)
        strSheets(icount) = sh.Name
        icount = icount + 1
    End If
    
    Next sh
    
    If icount = 0 Then
        MsgBox "A PDF cannot be created because no sheets were found.", , "No Sheets Found"
        Exit Sub
    End If
    
    ' Prompt for save location
    strfile = "Sheets" & "_" _
    & Format(Now(), "yyyymmdd_hhmmss") _
    & ".pdf"
    strfile = ThisWorkbook.path & "\" & strfile
    myfile = Application.GetSaveAsFilename _
    (InitialFileName:=strfile, _
    FileFilter:="PDF Files (*.pdf), *.pdf", _
    Title:="Select Folder and File Name to Save as PDF")
    
    If myfile <> "False" Then 'save as PDF
        
        ActiveWorkbook.ExportAsFixedFormat xlTypePDF, myfile & ".pdf", _
                                       xlQualityStandard, , , , , True
        
    Else
        MsgBox "No File Selected. PDF will not be saved", vbInformation, "No File Selected"
    End If
End Sub

以上是关于vbscript 使用文件对话框将工作簿导出为PDF的主要内容,如果未能解决你的问题,请参考以下文章

vbscript 将整个工作簿导出为PDF

vbscript 将表格导出到新工作簿

EXCEL的多个工作表如何导出单个EXCEL工作表

将查询导出为共享工作簿

python 此快速功能将excel文件中的所有工作簿导出为单独的csv,以使数据更易于使用。

通过对话框将当前工作簿另存为单独的 Excel 工作簿 [重复]