在copypicture之后,Excel图像不会导出为PDF

时间:2017-09-27 07:27:24

标签: excel vba excel-vba pdf

已经将一系列单元格作为图片复制到单独的工作表中here.单元格范围会根据另一个工作表上的自我选择自动填充 - 因此这有效地构建了一系列图像和指标包

现在已写入要导出为PDF的内容 - 打印区域使用偏移功能,具体取决于所选指标的数量。

但导出到PDF会运行但不会拍摄照片 - 你能帮忙吗?

Sub printPDFSave()

Dim rng As Range
Dim fPathFile As Variant

Set rng = [Destination]

fPathFile = Application.GetSaveAsFilename(filefilter:="PDF Files (*.pdf), *.pdf")
If fPathFile <> False Then
    rng.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fPathFile,  Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False,  OpenAfterPublish:=False
End If

End Sub

1 个答案:

答案 0 :(得分:0)

请尝试以下..我们假设图片在sheet2中

Option Explicit

Sub printPDFSave()

Dim rng As Range
Dim fPathFile As Variant
Dim sh As Shape
Dim ShRow As Long

For Each sh In Sheet2.Shapes
    ShRow = sh.BottomRightCell.Row
Nex

Set rng = Sheet2.Range("A1:K" & ShRow)

fPathFile = Application.GetSaveAsFilename(filefilter:="PDF Files (*.pdf), *.pdf")

If fPathFile <> False Then
    rng.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fPathFile, Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End If

End Sub