Pdf file direkt per Commandbutton
28.08.2003 14:44:59
Tobias Widmer
Ich habe das folgende Makro, das mir das File downloaded und auch Ausdruckt, das Problem ist jetzt, dass wenn ich das Makro per button starte eine Fehlermeldung erscheint, dass das zudruckende File nicht vorhanden ist.
Wenn ich aber das Makro aus dem Editor Schritt für Schritt laufen lasse funktioniert das Makro, d.h. macht den download und druckt das pdf aus.
Kann mir jemand da weiterhelfen oder kennt jemand eine andere Möglichkeit um im excel per knopfdruck ein pdf file downzuloaden und dann auch automatisch auszudrucken?
Das Makro:
Private Declare
Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL$, ByVal szFileName$, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Public Declare
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
Sub printmakro()
Product = "C:\Example.pdf"
If Worksheets(1).CheckBox1.Value = True Then
sURL$ = "http://www.beispiel.de"
sLocalFile$ = Product
lResult = URLDownloadToFile(0, sURL$, sLocalFile$, 0, 0)
ShellExecute 0, "Print", Product, "", "", SHOWMAXIMIZED
End If
End Sub
Mfg Tobias Widmer