Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Form With Embedded Browser 2

Status
Not open for further replies.

MikeC14081972

Programmer
May 31, 2006
137
GB
I have a form with an embedded Microsoft Web Browser Active X Control (calledWebBrowser)

The browser will load the required site but I'm having problems entering a value to a control on the webpage.

Code Below:

Code:
Dim strURL As String
Dim IE As Object


    strURL = "Website Address"
    Set IE = Me.WebBrowser.Object

    IE.Navigate strURL
   
    
    With IE
        .Document.all("SearchValue").select
        .Document.all("SearchValue").Value = "Required Value"
        .Document.all("Submit").select
        .Document.all("Submit").Click
    End With

The code fails on the line

Code:
 .document.all("SearchValue").select

with error 91: Object Variable or With Block Variable not set.

By stepping through the code you can force the code to work but not when running normally.

Does anyone know the answer ?

If you make something idiot proof - They'll Only make a better idiot!!!
 
I could be wrong but in my browser after I do a Navigate I loop until I know what screen returned.

HTH RuralGuy (RG for short) acXP winXP Pro
Please respond to this forum so all may benefit
 
Code:
Set IE = Me.WebBrowser1
 IE.Navigate strURL
 Do 'Additional checking
    If IE.ReadyState = READYSTATE_COMPLETE Then Exit Do
    DoEvents
    
 Loop

I use something like the above code
 
Many Thanks

By adding after the IE.Navigate

Code:
While IE.Busy
        DoEvents
Wend



The problem was solved. It didn't register to me that the site hadn't loaded and I was trying to pass values to a control that didn't exist. It would also explain why, by stepping through the code it would work on the 3rd or 4th attempt.

If you make something idiot proof - They'll Only make a better idiot!!!
 
Sorry Guys one more question.

How do I get Access to printout the loaded webpage.

Thanks in Advance.

If you make something idiot proof - They'll Only make a better idiot!!!
 
what about this ?
IE.ExecWB 6, 0 '6=OLECMDID_PRINT

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV,

Many Thanks but that didn't work, It did however point us in the right direction.

The answer we found was

Code:
IE.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER

If you make something idiot proof - They'll Only make a better idiot!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top