Access Microsoft Access Form, Need to print webpage.

Joined
Feb 12, 2013
Messages
1
Reaction score
0
Hello,

I am using VBA to write a form in access that will automatically open up a pdf located on a webserver and then print it.

I can get it to open the page in IE but I can't seem to get it to print. Please see the most recent code I have tried. I have tried several others but so far have had the best results with this.

Private Sub Command4_Click()


Const OLECMDID_PRINT = 6
Const OLECMDEXECOPT_DONTPROMPTUSER = 2
Const PRINT_WAITFORCOMPLETION = 2

Dim oIExplorer: Set oIExplorer = CreateObject("InternetExplorer.Application")
oIExplorer.Navigate me.msds_filepath
oIExplorer.Visible = 1

Do While oIExplorer.ReadyState <> 4
wscript.Sleep (1000)
Loop

oIExplorer.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
End Sub

For some reason when I type in my actual field in the oIEexplorer.navigate it opens the webpage but throws the exception "Runtime Error 424; Object Required" on the wscript.Sleep(1000) line when it tries to print. If I just type a random webpage in there like www.google.com it opens fine and prints fine.

Please help me with this if possible!

Thanx!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top