VBA批量打印PDF

Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long
Sub Auto_Open()
Dim mypath$, s$
Dim i&
Application.ScreenUpdating = False
With Application.FileDialog(msoFileDialogFilePicker)
    .Filters.Add "All pdf files", "*.pdf", 1            'PDFfile
    .AllowMultiSelect = True        'MultiSelect
    If .Show Then mypath = .SelectedItems(1) Else Exit Sub
  For i = 1 To .SelectedItems.Count
        s = .SelectedItems(i)
        ShellExecute Application.hwnd, "print", s, "", "", SW_HIDE
    Next
End With
End Sub

  

posted @ 2024-10-23 09:29  tec2019  阅读(30)  评论(0编辑  收藏  举报