+ Reply to Thread
Results 1 to 6 of 6

.document.getElementsbyname not recognising name

  1. #1
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2016 (Office 365)
    Posts
    137

    .document.getElementsbyname not recognising name

    Hi all,

    I am having trouble with a macro that logs onto a weather information website and adds some weather codes. The demo file I have below opens a website, logs in and then enters weather codes and submits the entry, works fine to here. Next it opens a new tab, navigates to a new page on the same site and tries to enter some of the codes again however the element name is not being recognised. I tried trouble shooting by finding the ID of the element I want and that works fine however I need the name so I can enter the values that I need and then submit.

    This is the code I am using, I have placed some comments around the problem code near the end:

    Please Login or Register  to view this content.
    See the attached file for a working demo if you need it.

    Can anyone see any obvious errors that I may be missing?

    Thanks for you assistance.
    Marcus
    Attached Files Attached Files

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: .document.getElementsbyname not recognising name

    I suggest you try it like this instead:

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2016 (Office 365)
    Posts
    137

    Re: .document.getElementsbyname not recognising name

    Hi there WBD,

    I have place your code into the program and still no joy.

    Please Login or Register  to view this content.
    this is still coming up as nothing hence the weather codes are not being entered. Works well on the first tab but for some reason not on the second.

    Marcus

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: .document.getElementsbyname not recognising name

    Hello demarc,

    Rather than use Internet Explorer, you can do this with more control with a Web Browser object and a UserForm. The code below is the macro to control the web browser. It will go to each page on the site and automatically fill in the data and click buttons. The attached workbook contains the UserForm and Web Browser object. The button "Login" calls the macro "Run" whichs open the UserForm.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Leith Ross; 02-25-2019 at 04:17 PM.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2016 (Office 365)
    Posts
    137

    Re: .document.getElementsbyname not recognising name

    Hi Leith,

    That is a neat solution!

    I have solved my issue though with a slight workaround in that instead of trying to add information and submit on a second tab I am just opening up a second instance if IE and doing it their, this seems to work fine. It is also handy that IE can open in the background on this particular app that I am developing as the information is not necessarily used straight away and it is probably referred to more than once during the planning process. With the userform not much else can be done while it is displayed.

    Thanks for you help, I will definitely keep that one in the bank for future projects.

    Cheers,
    Marcus

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: .document.getElementsbyname not recognising name

    Hello Marcus,

    Glad you like it. Congratulations for finding a solution on your own! On aside note, the UserForm can be displayed as Modeless which allows you to interact with Excel.

+ 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. Set FillHistory as iedoc.getElementsByName("name) fail randomly
    By n07cn3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-23-2017, 05:03 PM
  2. [SOLVED] Recognising Conflicts
    By bananas123 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-24-2014, 10:38 AM
  3. [SOLVED] Not recognising dates
    By markDuffy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-21-2014, 12:51 PM
  4. Macro not recognising changes
    By grey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-22-2012, 05:20 AM
  5. Drop down not recognising
    By stevesunfold in forum Excel General
    Replies: 2
    Last Post: 11-24-2008, 04:09 PM
  6. Recognising the first non-zero value over 13 columns
    By Tricia in forum Excel General
    Replies: 2
    Last Post: 07-10-2008, 01:33 AM
  7. Not recognising two values are the same
    By Big Mark in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2008, 07:52 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