標題:
如何用VBA批次轉檔成為PDF加密檔案?
[打印本頁]
作者:
JasonChen576
時間:
2018-2-9 13:56
標題:
如何用VBA批次轉檔成為PDF加密檔案?
目前只找到使用引用PDFCreator。
但有無比較簡單的方法呢?
作者:
Hsieh
時間:
2018-2-9 15:08
回復
1#
JasonChen576
試試看
Sub CreatePDF()
Dim Sh As Worksheet
Application.ScreenUpdating = False
Set fdo = CreateObject("Scripting.FileSystemObject")
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "選擇EXCEL檔案所在資料夾"
.Show
fd = .SelectedItems(1)
f = IIf(fdo.driveExists(fd), "", "\") '判斷是是磁碟或資料夾
End With
If fdo.FolderExists(fd & f & "PDF") = False Then fdo.CreateFolder fd & f & "PDF" '在來源資料夾新增存放PDF的目的資料夾
fs = Dir(fd & f & "*xls*")
Do Until fs = ""
With Workbooks.Open(fd & "\" & fs)
For Each Sh In .Sheets '每個工作表做一個PDF檔案
With Sh
If Application.CountA(.Cells) > 0 Then
.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
fd & "\PDF\" & fs & Sh.Name & ".pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
End If
End With
Next
.Close 0
End With
fs = Dir
Loop
Application.ScreenUpdating = True
End Sub
複製代碼
作者:
JasonChen576
時間:
2018-2-14 13:46
回復
2#
Hsieh
感謝大大賜教∼
請問PDF如果要加上密碼呢?
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)