Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I automatically print file path on documents Brenda @ FCA Excel Discussion (Misc queries) 6 May 17th 07 02:55 PM
Want to Automatically Re-Categorize a Downloaded Internet Spreadsheet The Moose Excel Discussion (Misc queries) 2 October 13th 06 10:24 AM
Automatically Open after Download Z Excel Discussion (Misc queries) 0 October 2nd 06 04:28 PM
Internet explorer download/XP Pro?? Maxwell-5000 Excel Discussion (Misc queries) 1 January 3rd 06 10:03 PM
Download from the Internet into Excel Edward Excel Discussion (Misc queries) 4 November 18th 05 04:59 PM


All times are GMT +1. The time now is 11:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"