PDA

View Full Version : Solved: Execute Commands in IE From Access



eed
09-03-2004, 01:03 PM
Hi, all,

I'm using the following chunk of code to output an Access query into HTML, then open the HTML file in Internet Explorer. The next step I would LIKE to accomplish is to select and copy the table from the Explorer window. I keep thinking that this should be simple enough, since Select All and Copy are just Edit menu commands, but I have not yet determined how to execute these commands in the Explorer window from my Access VBA. Any thoughts? Thanks in advance!! :hi:


Private Sub Command110_Click()
Dim strPath As String, strOCR As String
Dim objIE As InternetExplorer
strPath = FixPath(CurrentProject.Path)
strOCR = strPath & "temp_ocr.html"

DoCmd.OutputTo acQuery, "QyOCR_Table_HTML", "HTML(*.html)", strOCR, False, ""

Set objIE = New InternetExplorer
With objIE
.Navigate strOCR
.Visible = True
End With

End Sub

smozgur
09-04-2004, 12:32 AM
Hi,

IE Object's ExecWB method for Select All and Copy action.

Private Sub Command110_Click()
Dim strPath As String, strOCR As String
Dim objIE As InternetExplorer
strPath = FixPath(CurrentProject.Path)
strOCR = strPath & "\temp_ocr.html"

DoCmd.OutputTo acQuery, "Query1", "HTML(*.html)", strOCR, False, ""

Set objIE = New InternetExplorer
With objIE
.Navigate strOCR
.Visible = True
End With

'Select All
objIE.ExecWB 17,2 'OLECMDID_SELECTALL, OLECMDEXECOPT_DONTPROMPTUSER
'Copy Selection
objIE.ExecWB 12,2 'OLECMDID_COPY, OLECMDEXECOPT_DONTPROMPTUSER
'Clear Selection
objIE.ExecWB 18,2 'OLECMDID_CLEARSELECTION, OLECMDEXECOPT_DONTPROMPTUSER

End Sub

I hope helps.
Suat

eed
09-07-2004, 05:49 AM
Okay, I'm running this piece of code:


Set objIE = New InternetExplorer
With objIE
.Navigate strOCR
.Visible = True
End With

objIE.ExecWB 17, 2 'OLECMDID_SELECTALL, OLECMDEXECOPT_DONTPROMPTUSER

objIE.ExecWB 12, 2 'OLECMDID_COPY, OLECMDEXECOPT_DONTPROMPTUSER


And I'm getting this error message:

-2147221248: Method ?ExecWB? of object ?IwebBrowser2? failed

Any ideas on what is causing that? :confused:

smozgur
09-07-2004, 06:05 AM
Please check your project references (VBA->Tools->References) and see if you have Microsoft Internet Controls is added in your project.

If it doesn't exist then please let us know which references you have.

Attaching your db here might help a lot (if not confidential).

Suat

Anne Troy
09-16-2004, 11:13 AM
Is this solved, eed?
Or can we help you further?

eed
09-16-2004, 11:17 AM
I'm sorry, yes, it's solved, well, closed, at least. My references were set, but I never could determine what was causing the error message.

My solution was giving up on the IE idea and just manipulating the HTML file through Word. I knew from the start of this post that was an option; it would have been a bonus to make the IE process work, but it wasn't necessary to my procedure, so I'm skipping it. :blush

Thanks anyway for everyone's great suggestions!

Anne Troy
09-16-2004, 11:24 AM
Great. :)

I think people who ask the questions can now mark their questions solved using the Thread Tools dropdown at the top of the thread, so... feel free from now on.

Thanks for getting back so quick!