Using VBA to print from a website

breecy

New Member
Joined
Mar 26, 2009
Messages
1
Good evening all,
I am trying to print from a web site that I have open. It prints just fine when I step through it, but when it runs it prints nothing. I have put a sleep sub to slow it down and that doesn't work. I have gone back to the do events. it does work if I display a message box for a user to click on. Please help. My code is as followings:

Code:
Function PrintWebSite(WebPage As String)
Dim ie As Object
Dim intwidth As Integer
Const OLECMDID_PRINT = 6
Const OLECMDEXECOPT_PROMPTUSER = 1
Const OLECMDEXECOPT_DONTPROMPTUSER = 2
******"I would like to use this but can't figure it out"************
'Const OLECMDEXECOPT_PRINT_WAITFORCOMPLETION
Set ie = CreateObject("InternetExplorer.Application")

ie.navigate WebPage
    Do Until ie.busy = False
        DoEvents
    Loop
    'Send Data to IE
'Prints without showing the user that the browser is open.
ie.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0
    Do While ie.readystate <> 4
        DoEvents
    Loop
    
    'Giving it time to print
ie.Quit
Set ie = Nothing
End Function
 
Last edited by a moderator:

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,214,788
Messages
6,121,588
Members
449,039
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top