標題:
[發問]
篩選後另存PDF遺失了標題列
[打印本頁]
作者:
missbb
時間:
2016-12-11 16:31
標題:
篩選後另存PDF遺失了標題列
大大, 請賜教,
有一個VBA檔, 篩選後另存PDF, 但沒有A1至J5的標題包括日期及星期, 請問未知那裡出錯?
[attach]26070[/attach]
作者:
missbb
時間:
2016-12-12 14:25
本帖最後由 missbb 於 2016-12-12 14:26 編輯
再試下列CODE, 都無法將ROW 1列出, 求大大賜教?
[code]Sub printPDF_4()
'pdf for shop reporting errors
Dim xPath As String
Dim d As Object
Dim A As Variant
Dim f As String
Dim ky As Variant
Dim rng As Range
ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address
Set rng = ActiveSheet.UsedRange
xPath = Application.ActiveWorkbook.Path
Set d = CreateObject("Scripting.Dictionary")
With Worksheets("attendance report")
For Each A In .Range(.[c3], .[c3].End(xlDown))
d(A.Value) = ""
Next
f = InputBox("輸入PDF檔的月份, 例:201508")
If f = "" Then Exit Sub
For Each ky In d.KEYS
.Range("c3").AutoFilter field:=3, Criteria1:=ky
If Dir(xPath & "\" & ky & "_" & f & ".pdf") <> "" Then Kill xPath & "\" & ky & "_" & f & ".pdf" '同名檔案刪除
rng.ExportAsFixedFormat Type:=xlTypePDF, fileName:= _
xPath & "\" & ky & "_" & f & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False '另存成PDF檔案
Next
If .FilterMode = True Then .ShowAllData '顯示所有資料
End With
End Sub
複製代碼
[/code]
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)