- 帖子
- 216
- 主題
- 71
- 精華
- 0
- 積分
- 292
- 點名
- 0
- 作業系統
- window xp
- 軟體版本
- 2007
- 閱讀權限
- 20
- 性別
- 女
- 註冊時間
- 2012-6-27
- 最後登錄
- 2024-9-28
|
2#
發表於 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] |
|