Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
automatically download and print a pdf file from the Internet
Hi to all
I have a problem with the following Macro, if I start the macro in the editor step by step it works perfectly ( it downloads a file from the Net and automatically prints it out), but if i assign the Macro to a button in the excel file and i then start the macro by pressing the button i get an error message ("The file does not exist! bla bla...") Does anybody know a solution to this problem or knows another macro to produce the same? thank you in advanced.... The macro: 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.example.com/example.pdf" sLocalFile$ = Product lResult = URLDownloadToFile(0, sURL$, sLocalFile$, 0, 0) 'I tried with DoEvents but it did not work ShellExecute 0, "Print", Product, "", "", SHOWMAXIMIZED Kill (Product) End If End Sub Regards Tobias Widmer |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
automatically download and print a pdf file from the Internet
perhaps
Sub printmakro() Product = "C:\Example.pdf" If Worksheets(1).CheckBox1.Value = True Then sURL$ = "http://www.example.com/example.pdf" sLocalFile$ = Product lResult = URLDownloadToFile(0, sURL$, sLocalFile$, 0, 0) 'I tried with DoEvents but it did not work do while dir(Product) = "" DoEvents Loop ShellExecute 0, "Print", Product, "", "", SHOWMAXIMIZED Kill (Product) End If End Sub -- Regards, Tom Ogilvy Tobias Widmer wrote in message om... Hi to all I have a problem with the following Macro, if I start the macro in the editor step by step it works perfectly ( it downloads a file from the Net and automatically prints it out), but if i assign the Macro to a button in the excel file and i then start the macro by pressing the button i get an error message ("The file does not exist! bla bla...") Does anybody know a solution to this problem or knows another macro to produce the same? thank you in advanced.... The macro: 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.example.com/example.pdf" sLocalFile$ = Product lResult = URLDownloadToFile(0, sURL$, sLocalFile$, 0, 0) 'I tried with DoEvents but it did not work ShellExecute 0, "Print", Product, "", "", SHOWMAXIMIZED Kill (Product) End If End Sub Regards Tobias Widmer |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I automatically print file path on documents | Excel Discussion (Misc queries) | |||
Want to Automatically Re-Categorize a Downloaded Internet Spreadsheet | Excel Discussion (Misc queries) | |||
Automatically Open after Download | Excel Discussion (Misc queries) | |||
Internet explorer download/XP Pro?? | Excel Discussion (Misc queries) | |||
Download from the Internet into Excel | Excel Discussion (Misc queries) |