+ Reply to Thread
Results 1 to 4 of 4

Filling forms in IE - Error 91

  1. #1
    Registered User
    Join Date
    06-07-2014
    Posts
    7

    Filling forms in IE - Error 91

    Hi All,
    I want to facilitate some task at my work and i want to use below code, though i have an issue with it. For testing i used gmail registration page. On my PC at home macro works, it fills input box with value from excel cell. But at my workplace same code doesn't work. There is Error 91 (Object variable or With block variable not set) - from what i have learnt it indicates that VBA couldn't find requested object. I tried to search web about it and only explanation i found was that page may not be loaded completely, but the macro works on already loaded page. Is it possible then that IE at my work is somehow protected and VBA is unable to retrieve elements from it?

    Here's the code i use (i found it on web):

    Sub GetIE()

    Dim shellWins As ShellWindows
    Dim IE As InternetExplorer


    Set shellWins = New ShellWindows


    If shellWins.Count > 0 Then
    ' Get IE
    Set IE = shellWins.Item(0)
    Else
    ' Create IE
    Set IE = New InternetExplorer
    IE.Visible = True
    End If
    entryV = Range("a1")
    Set UserN = IE.Document.getElementsByName("FirstName")
    If Not UserN Is Nothing Then
    UserN(0).Value = entryV
    End If


    Set IE = Nothing
    Set shellWins = Nothing


    End Sub

    Thank you in advance.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Filling forms in IE - Error 91

    Your code won't always work on an existing instance of IE.

    If sheetWins.Count is 0 then a new instance will be created.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    06-07-2014
    Posts
    7

    Re: Filling forms in IE - Error 91

    But if new instance isn't created, i can assume macro works on existing page. Anyway i tried also code which opens IE then goes to google registration page and still it doesn't work. The issue is that VBA is not able to find element in IE and i don't know why.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Filling forms in IE - Error 91

    If you are working with a new instance of IE and navigating to a particular site/page then you will need code that will wait until the site/page has fully loaded.

    There are many examples of that type of code on this forum.

    By the way, testing this code on sites that are unlike the site you actually want to work with is, well, kind of pointless.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Forms: system error + error 361
    By opopanax666 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-19-2008, 07:25 AM
  2. Filling Forms
    By formfiller in forum Excel General
    Replies: 2
    Last Post: 10-31-2007, 11:07 PM
  3. filling forms
    By TravisT81 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-29-2007, 01:52 PM
  4. filling combox box with same logic in 2 <> forms
    By François in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-31-2006, 07:10 AM
  5. Replies: 1
    Last Post: 02-13-2006, 03:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1