PC Review


Reply
Thread Tools Rate Thread

automatically download and print a pdf file from the Internet

 
 
Tobias Widmer
Guest
Posts: n/a
 
      30th Aug 2003
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 With Quote
 
 
 
 
Tom Ogilvy
Guest
Posts: n/a
 
      30th Aug 2003
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 <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visata automatically deltes the files i download from internet Elchin Windows Vista Security 4 9th Jul 2008 05:16 AM
IE 6.0 Unable to Download files - Attempting to When you attempt to download a file from a Web site, the Copying dialog box may appear ... Internet Explorer Window Closes When You Click a Download Link . Robert Cox Windows XP Internet Explorer 6 5th Sep 2007 09:08 PM
ZIP file automatically download :( =?Utf-8?B?R29fbGFu?= Windows XP Internet Explorer 2 22nd May 2005 03:25 PM
trying to download a file (application) from internet to print... =?Utf-8?B?ZmlyZW5haXI=?= Windows XP Help 0 4th Apr 2005 02:21 AM
How to automatically download a file Mota Microsoft Access Form Coding 3 2nd Aug 2004 03:26 AM


Features
 

Advertising
 

Newsgroups
 


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