I have a database designed in 2k that contains a WebBrowser activeX control that, at one point, is used to display and print a PDF file on a web server. This has worked fine when using 2k however our organisation is changing to 2010, a big jump. While the control still works to display web pages and the pdf file, the code I have used to print it seems to no longer work and does not spit out any error messages. Code below is what I have been using, sorry forgot how code should be posted here. Any suggestions as to how to get this to work in 2010? IE7 is being used with windows XP, neither of which have changed.
Function Brochure(BrowserNo)
Dim web
On Error GoTo errorHandler
web = "WebBrowser" & BrowserNo
Forms(FormMain)(web).Navigate2 "http://www.somewebsite/somepdffile.pdf"
‘WaitWebBrowser2 is just a function used to make it wait until the full page has loaded
crap = WaitWebBrowser2(BrowserNo)
' for some reason you need to make this one pause for a few second otherwise the page does not print
‘this was needed in 2k version to give the pdf a little time to load.
‘I tried extending this but just ended up waiting a long time
For a = 1 To 5000
DoEvents
Next a
‘This is the line that prints no longer
Forms(FormMain)(web).ExecWB OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER
‘although it does not actually print the function still returns true with no error being captured.
Brochure = True
Exit Function
errorHandler:
Brochure = False
errNameFrom = "WebStuff.Brochure"
crap = General.HandleErrors(Err.Number, Err.Description)
End Function
Function Brochure(BrowserNo)
Dim web
On Error GoTo errorHandler
web = "WebBrowser" & BrowserNo
Forms(FormMain)(web).Navigate2 "http://www.somewebsite/somepdffile.pdf"
‘WaitWebBrowser2 is just a function used to make it wait until the full page has loaded
crap = WaitWebBrowser2(BrowserNo)
' for some reason you need to make this one pause for a few second otherwise the page does not print
‘this was needed in 2k version to give the pdf a little time to load.
‘I tried extending this but just ended up waiting a long time
For a = 1 To 5000
DoEvents
Next a
‘This is the line that prints no longer
Forms(FormMain)(web).ExecWB OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER
‘although it does not actually print the function still returns true with no error being captured.
Brochure = True
Exit Function
errorHandler:
Brochure = False
errNameFrom = "WebStuff.Brochure"
crap = General.HandleErrors(Err.Number, Err.Description)
End Function