TextBox and Multipage with Webcontrol on Userform in Excel

sanits591

Active Member
Joined
May 30, 2010
Messages
253
Hi,

I have a Userform with following controls pasted on it:
1. One Textbox on Userform
2. One Multipage control (p) on Userfrom, with 5 pages.
3. 2 Webcontrols on Multipage of page1

Now the problem is, as soon as i type in the textbox then webcontrol on p gets the required webpage according to the textbox, but as soon as i come back from page2 of p and then click on the textbox the error comes.

Here, below, i am giving the code for the same, requesting to guide, how to get rid of the errors.

Code:
Private Sub TextBox1_Change()

Dim strURL As String
    
If Me.MultiPage1.SelectedItem.Index = 0 Then
    If TextBox1.Text <> "" Then
    strURL = "http://a" & Me.TextBox1.Text
        Me.WebBrowser1.Navigate strURL
        Me.WebBrowser2.Navigate strURL
    End If
    
ElseIf Me.MultiPage1.SelectedItem.Index = 1 Then
    MsgBox "2nd page selected"
End If

End Sub

Thanks!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
It's very hard to troubleshoot if you don't tell us what error you are getting and on which line of code.
Also, I would suggest not using the Change event, since that is triggered with every keystroke in the textbox.
 
Upvote 0
Thanks! for responding to it!. I get an error,

"Run time error '-2147467259 (80004005)':
Method navigate of object 'IWebbrowser2' failed.

This error comes in Me.WebBrowser1.Navigate strURL

Request to assist on this.
 
Upvote 0
That would imply that the URL is invalid. Not really surprising if you try and navigate on every keypress... ;)
 
Upvote 0
rorya, it's a bit more than that; the webbrowswer seems to disappear once you've clicked to another page and back. I played with this but got nowhere (hence no posting from me on this). If you move one of the webbrowsers off the multipage control directly onto the userform, that one works, the one on the multipage doesn't. I googled and found several people had had the same experience, but no-one had come up with a solution, only workarounds, mostly involving ditching the multipage. The problem persists in Excel 2010.
 
Upvote 0
You're quite right. Apologies - I should have tested first.
In reality that doesn't surprise me particularly since the multipage has never worked well with non-MSForms controls (e.g. the RefEdit). I suspect that using a TabStrip might be the easiest option if the effect of a multipage is required.
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,259
Members
452,901
Latest member
LisaGo

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