- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 88
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2025-4-12
               
|
3#
發表於 2015-7-30 23:15
| 只看該作者
回復 2# missbb
2007版是否已有另存成PDF檔功能?
以下在2010版本可行- Sub ex()
- Set d = CreateObject("Scripting.Dictionary")
- With ActiveSheet
- For Each a In .Range(.[E4], .[E4].End(xlDown))
- d(a.Value) = "" '取得所有不重複分店
- Next
- For Each ky In d.keys
- .Range("B4").AutoFilter field:=4, Criteria1:=ky
- If Dir("D:\" & ky & ".pdf") <> "" Then Kill "D:\" & ky & ".pdf" '同名檔案刪除
- .ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
- "D:\" & ky & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, _
- IgnorePrintAreas:=False, OpenAfterPublish:=True '另存成PDF檔案
- Next
- If .FilterMode = True Then .ShowAllData '顯示所有資料
- End With
- End Sub
複製代碼 |
|