2017-09-27 77 views
0

已將圖片單元格的範圍複製到單獨的工作表中here.單元格範圍根據另一個工作表上的自我選擇自動填充 - 因此,這樣可以有效地生成一系列圖像,是和指標包。複製圖片後不導出爲PDF的Excel圖像

現在已經寫了一些內容導出爲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 
+0

您可以檢查是否爲圖像的屬性'打印object'設置? (右鍵單擊圖像,「格式圖片」,「屬性」) – FunThomas

+0

是打印對象被選中 – tj123

回答

0

請嘗試below..we假設圖像是在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 
+0

謝謝 - 但我的範圍是動態的,所以它始終在列A:K,但可以是不同的行長度......這就是爲什麼我已經命名了偏移量[目的地]。 – tj123

+0

請再次檢查...我用動態行做了它 –