jensgebken
Goto Top

Access - VBA - Ausdruck einer PDF Datei

Hallo Gemeinschaft,

möchte gerne per vba eine pdf Datei ausdrucken

habe in meiner db die vollständige Adresse zur pdf Datei hinterlegt und möchte diese per klick ausdrucken

könnt ihr da helfen

Content-Key: 8630617063

Url: https://administrator.de/contentid/8630617063

Printed on: April 27, 2024 at 12:04 o'clock

Mitglied: 10138557388
Solution 10138557388 Dec 30, 2023, updated at Jan 02, 2024 at 16:43:50 (UTC)
Goto Top
Declare PtrSafe Function apiShellExecute 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  

Public Sub PrintFile(ByVal strFile As String)
    Dim inthWnd As Long
    inthWnd = IIf(Application.Name = "Microsoft Access", hWndAccessApp, hwnd)  
    Call apiShellExecute(inthWnd, "print", strFile, vbNullString, vbNullString, 0)  
End Sub

Sub Test()
   PrintFile "C:\Test.pdf"  
End Sub
Member: jensgebken
jensgebken Jan 02, 2024 at 16:08:36 (UTC)
Goto Top
hi pjumper - bekomme das script leider nicht zum laufen auf einem 64 bit

habe diesen code so geändert
Declare PtrSafe Function apiShellExecute 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  

bekomme dann bei der ausführung des printbefehls aber diesen fehler
Object unterstützt die methode nicht
Mitglied: 10138557388
10138557388 Jan 02, 2024 updated at 16:45:32 (UTC)
Goto Top
Application.hWnd war noch für eine andere Office-Anwendung, bitte ändern in Application.hWndAccessApp

Habe das oben etwas angepasst. Klappt hier dann problemlos.
Member: jensgebken
jensgebken Jan 03, 2024 at 12:44:16 (UTC)
Goto Top
suuuuper klasse