AW: die PDF-Dateien eines Ordners auf aktivem Drucker ausgeben
21.10.2023 10:50:01
Alwin Weisangler
Hallo Jochen,
teste mal:
Option Explicit
Public Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Dim arrPdfList()
Sub allePDF_Holen()
Dim strPath$, strFile$, i&, Thema As Variant
If strPath = "" Then strPath = ShellVerzeichnisBrowser
If strPath > "" Then
strPath = IIf(Right(strPath, 1) = "\", strPath, strPath & "\")
strFile = Dir(strPath & "*.pdf", vbNormal)
Do While strFile > ""
i = i + 1
ReDim Preserve arrPdfList(1 To 1, 1 To i)
arrPdfList(1, i) = strFile
strFile = Dir
Loop
End If
allePDF_drucken
End Sub
Sub allePDF_drucken()
Dim varPdf, sURL, sLocalFile, lResult, SHOWMAXIMIZED, i&
For i = 1 To UBound(arrPdfList, 2)
ShellExecute 0, "open", arrPdfList(1, i), "", "", SHOWMAXIMIZED
ShellExecute 0, "print", arrPdfList(1, i), "", "", SHOWMAXIMIZED
ShellExecute 0, "exit", arrPdfList(1, i), "", "", SHOWMAXIMIZED
Next i
End Sub
Private Function ShellVerzeichnisBrowser(Optional ByVal defaultPath = "") As String
Dim objItem As Object, objShell As Object, objFolder As Object
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0&, "Bitte Verzeichnis anklicken", 0&, defaultPath)
If objFolder Is Nothing Then GoTo weiter
Set objItem = objFolder.Self
ShellVerzeichnisBrowser = objItem.Path
weiter:
Set objShell = Nothing
Set objFolder = Nothing
Set objItem = Nothing
End Function
Gruß Uwe