Announcement

Collapse
No announcement yet.

WebBrowser control only displays a blank screen

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • WebBrowser control only displays a blank screen



    I have searched and found a lot of references to the web browser control for a user form. I have tried and tried but all I get is a blank webbrowser control.

    I have tried the navigate and navigate2 methods and other stuff that you can see that I have commented out. Also, I tried placing the line with the navigate method both before and after the userform.show method. But all I get is a blank web browser on the form.

    Here is what (sort of) I have tried:

    Code:
    Sub ShowTheForm()
        'Dim myPerm As Office.Permission
        'Set myPerm = ThisWorkbook.Permission
        'myPerm.EnableTrustedBrowser = True
        'Of course this permission stuff was fruitless
    
        UserForm1.Show
        WebBrowser1.Navigate "J:\temp\WebBrowser1.html"
        'WebBrowser1.Navigate "file://j:\temp\WebBrowser1_image.jpg"
        
    End Sub
    So, what's the trick. All the stuff I found searching the web implies that what I have above should work.

    Regards Jim

  • #2
    Re: WebBrowser control only displays a blank screen

    Try this - assuming you want the WebBrowser to open a local .html file as shown by your code. Note the 3 forward slashes following "file:" and %20 to encode a space. Open the .html file in your browser and use the URL shown in the address bar if you're not sure what the Navigate string should be.

    Module1
    Code:
    Sub Show_Form()
        Dim frm As UserForm1
        Set frm = New UserForm1
        frm.Show
    End Sub
    UserForm1
    Code:
    Private Sub UserForm_Initialize()
        WebBrowser1.Navigate "file:///C:/Test%20files/temp.html"
    End Sub

    Comment


    • #3
      Re: WebBrowser control only displays a blank screen

      Bummer.

      I tried again and still all I get is a blank browser control on the form. I moved the html file to my local c:\ drive instead of the mapped drive to our network server file space and there are no spaces to be concerned with, tried both forward and back slashes. I tried one of the infamous search sites, too. I tried (again) placing the .show command before and after the .navigate command.

      Here is my code again with all of the paths I tried (all but one commented):

      Code:
      Sub ShowTheForm()
          UserForm1.Show
          'WebBrowser1.Navigate "file:///j:/temp/WebBrowser1_image.jpg"
          'WebBrowser1.Navigate "J:\temp\WebBrowser1.html"
          'WebBrowser1.Navigate "file:///c:/temp/WebBrowser1.html"
          'WebBrowser1.Navigate "file:///c:\temp\WebBrowser1.html"
          'WebBrowser1.Navigate "c:\temp\WebBrowser1.html"
          WebBrowser1.Navigate "http://www.google.com"
      End Sub
      I'm wondering if there is some setting that I need to change or if our company's IT department has done something to prevent this from working; we can't even use the MSI installer utility.

      Comment


      • #4
        Re: WebBrowser control only displays a blank screen

        P.S. I am using Excel 2010 on Windows XP, in case that makes any difference.

        Comment


        • #5
          Re: WebBrowser control only displays a blank screen

          Hi again; and sorry for being so stupid. The control works and the navigate method works, if you put the code in a regular module and not in with the userform code module.
          (DUH!) LOL

          Comment


          • #6
            Re: WebBrowser control only displays a blank screen

            My code works with the .Navigate in the userform module. Look carefully at the module names in my post which indicate where each piece of code should reside and it should work for you too.

            Comment


            • #7
              Re: WebBrowser control only displays a blank screen

              Here's an example workbook with a web browser in.
              Attached Files
              Hope that Helps

              Roy

              New users should read the Forum Rules before posting

              For free Excel tools & articles visit my web site

              RoyUK's Web Site

              royUK's Database Form

              Where to paste code from the Forum

              About me.

              Comment


              • #8


                I appreciate that this is a very old post, but this is exactly the problem I am wrangling with. The excellent example works with a web address, but I want to do the same with a local html file which contains an interactive map. The example spreadsheet reads the html file and opens the web browser but with no content. The html file will open in internet explorer outside of excel. Any help would be appreciated. I am working with excel 2010.
                Many thanks
                Angela

                Comment

                Working...
                X