通过VBA将工作表导出为PDF并放大

时间:2019-03-06 10:11:00

标签: excel vba

我已经有一个导出到PDF的代码,它可以导出选定的图纸,但是我想使PDF文件中的图纸中导出的选择更大,以帮助以后的打印阶段。

以下是执行导出的代码:

Sub PDFActiveSheet()
    Dim wsA 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
    On Error GoTo errHandler

    Set wbA = ActiveWorkbook
    Set wsA = ActiveSheet
    strTime = Format(Now(), "yyyymmdd\_hhmm")

    strPath = wbA.Path
    If strPath = "" Then
      strPath = Application.DefaultFilePath
    End If
    strPath = strPath & "\"

    strName = Replace(wsA.Name, " ", "")
    strName = Replace(strName, ".", "_")

    strFile = strName & "_" & strTime & ".pdf"
    strPathFile = strPath & strFile

    myFile = Application.GetSaveAsFilename _
        (InitialFileName:=strPathFile, _
            FileFilter:="PDF Files (*.pdf), *.pdf", _
            Title:="Select Folder and FileName to save")

    If myFile <> "False" Then
        wsA.ExportAsFixedFormat _
            Type:=xlTypePDF, _
            Filename:=myFile, _
            Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, _
            IgnorePrintAreas:=False, _
            OpenAfterPublish:=False

        MsgBox "Les QrCodes ont été exporter dans le fichier PDF" _
          & vbCrLf _
          & myFile
    End If

exitHandler:
    Exit Sub
errHandler:
    MsgBox "Erreur lors de l'exportation"
    Resume exitHandler
End Sub

1 个答案:

答案 0 :(得分:1)

如果您只想放大固定百分比,请在导出行之前使用以下命令

wsA.PageSetup.Zoom = 150