Results 1 to 6 of 6
  1. #1
    naeemahmad is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Location
    Riverside, USA
    Posts
    46

    Post Web Browser Control Error 91 Object Variable Not Set

    Hi Experts,



    I'm hoping someone can help shed some light on a issue I am having with MS Access 2013 using Active X Web Browser Controls in Windows 10.

    I am a intermediate dev working with VBA, so heres my issue;

    I would like my form On Load event to navigate to a URL and then change some the Web Control Browser properties.

    Below is the code I am currently trying to make work;

    Code:
    Private Sub Form_Load()
    Dim objWB As Object
    WebBrowserGIF.Navigate "about:blank"
    
    While WebBrowserGIF.busy
    DoEvents
    Wend
        
    Set objWB = Me.WebBrowserGIF.Object
    With objWB
        Forms![frmADMIN]![WebBrowserGIF].Navigate "C:\Sample.gif"
        Forms![frmADMIN]![WebBrowserGIF].Document.Body.setattribute "scroll", "no"   <-- err 91 starts here
        Forms![frmADMIN]![WebBrowserGIF].Document.Body.bgcolor = &H0
        Forms![frmADMIN]![WebBrowserGIF].BorderStyle = 0
        Forms![frmADMIN]![WebBrowserGIF].BorderColor = vbBlack
    End With
    End Sub
    When I run the above code, it gives error of 91, BUT I can just F8 through the rest of the code and all works as intended !?

    Can someone please help me with the script or provide a better example, method or approach?

    Ive been looking around the web so search for answers/help, and not much luck yet.



    Thanks to all in advance!

  2. #2
    Mickjav is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Location
    Margate, Kent
    Posts
    123
    Try moving this
    Set objWB = Me.WebBrowserGIF.Object

    Above

    While WebBrowserGIF.busy

    Or just below the dim

    Hope it works

    mick

  3. #3
    naeemahmad is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Location
    Riverside, USA
    Posts
    46
    Thanks for your reply Mickjav, but still get the same error.

    I may not be setting the object correctly

    Ive been working on this for some days now and its driving me NuTz!

    Anyone that can help with this issue is greatly appreciated!

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    This doesn't look right
    Document.Body.setattribute "scroll", "no"

    try
    Document.Body.setattribute("scroll", "no")
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    naeemahmad is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Location
    Riverside, USA
    Posts
    46
    Hey Micron,

    I tried your suggestion, but did not work.

    I still have not figured out whats going on!?

    Any suggestions very appreciated. Thx

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I don't have a history of using these things but here's what I found when I copied your code, changed the form name to one of mine and set an image path:

    First, your code won't compile - I get a similar error that at first I figured was related but turned out not to be the issue. Failure to compile was due to .Navigate, and there is no method, event or property by that name shown here: https://docs.microsoft.com/en-us/off...browsercontrol
    After I set the ControlSource property instead, the compile error went away. Then I stepped through the code and it worked with my modifications. Then I allowed the code to run normally and if failed as it does for you. Then I tried introducing 2 and even 4 second pauses in various places before that line but that didn't help.
    I found that if I just set a break point it works with or without the pause. If I comment out the offending line, the issue shifts to a subsequent line - but again, works if I set a break.

    I also see that there are other properties and methods in the code that aren't documented at the link provided so I'm kind of at a loss. Perhaps you got that code from a VB or VB.Net site and didn't notice it wasn't VBA? Maybe that's the bigger issue.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 08-16-2017, 11:43 AM
  2. Error 91 Object Variable or Block Variable Not Set
    By mindbender in forum Programming
    Replies: 5
    Last Post: 05-01-2017, 12:01 PM
  3. Replies: 6
    Last Post: 02-11-2016, 02:05 PM
  4. Object variable not set (Error 91)
    By shabyr in forum Access
    Replies: 16
    Last Post: 07-18-2012, 03:10 PM
  5. Replies: 6
    Last Post: 09-28-2011, 09:20 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums