+ Reply to Thread
Results 1 to 29 of 29

VBA Internet Explorer - Select Button *** HELP ***

  1. #1
    Registered User
    Join Date
    11-25-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    VBA Internet Explorer - Select Button *** HELP ***

    Hi All,

    I am trying to automate the upload of data within Excel into SalesForce.com.

    I have managed to complete 90% of the macro but am stuck on clicking a button and radio button on a pop up window. I have managed to locate the window and make it the prime window, but cannot seem to click the button.

    Here's the code of the internet page, the button is on the very last line:

    HTML Code: 

    I have tried the following without luck:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    If anyone knows how to solve this i would be extremely grateful - also, if i have done anything wrong within my post please accept my apologies - this is my first

    Thanks in advance

    Freddie

  2. #2
    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: VBA Internet Explorer - Select Button *** HELP ***

    Hello Freddie,

    The "Go" button is on an HTML Form. This is a separate HTML document from the parent document. Once changes have been made to the Form, it must be "Sumbmitted" to the server before the actions will be carried out.

    Using the attribute "getElementByName" is not supported by the Input Submit element. It supports only "getElementById". But, this Input element does not have an ID. Since there are only two Input elements, you can return it this way...
    Please Login or Register  to view this content.
    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!)

  3. #3
    Registered User
    Join Date
    11-25-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: VBA Internet Explorer - Select Button *** HELP ***

    Hi Leith,

    Thanks so much for the reply.

    Unfortunately, it didn't work - it kicks out a Run Time 424 Error (Object Required) on the line "Set oForm = w.document.getElementById("theForm")"

    I have put the full code of where this takes place so you can see that i am naming the 2nd window w - i have adapted your code to call it via w instead of IE.

    Please Login or Register  to view this content.
    Thanks again for your help in advance.

    BR.

    Freddie
    Last edited by vbafreddie; 12-11-2014 at 05:22 PM.

  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: VBA Internet Explorer - Select Button *** HELP ***

    Hello Freddie,

    You should post the workbook, so I can review your code. I think the prtoblem is with "w". You are most likely returning a interface object and not an executable object.

    How To Post Your Workbook
    1. At the bottom right of the Reply window, Click the button Go Advanced
    2. At the top of the Your Message Window, in the first row of icons, Click the Paperclip icon.
    3. Click the Add Files button at the top right in the dialog box. This displays the File Manager dialog.
    4. Click the Select Files button at the bottom middle of the dialog.
    5. In the new window Find the file you want to upload, select it, and Click Open.
    6. You will now be back in the File Manager dialog. Click the bottom Middle button Upload File.
    7. Wait until the file has completely uploaded before you exit the File Manager dialog.

  5. #5
    Registered User
    Join Date
    11-25-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: VBA Internet Explorer - Select Button *** HELP ***

    Hi Leith,

    No worries, here we go.

    Thanks again!

    Freddie
    Attached Files Attached Files
    Last edited by vbafreddie; 12-11-2014 at 05:55 PM.

  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: VBA Internet Explorer - Select Button *** HELP ***

    Hello Freddie,

    I needs some background on what is happening. My assumption is you are logging into the site first and then retrieving data from one or more pages and after that I am not sure.

  7. #7
    Registered User
    Join Date
    11-25-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: VBA Internet Explorer - Select Button *** HELP ***

    Sorry Leith,

    Yeah you're right - firstly it logs into the site.

    Then navigates to a particular page, where the data entry starts (the code loops through deleting every line that it puts into the website). This finishes here " 'Opens Lookup Window - SFDC"

    This is then where i am stuck. It opens the popup window which is being defined (or at least i think it is) as "w" which also uses some code inside the module "PopupWindow".

    Inside this popup (theform) i need to select the radio button "all fields" and click "Go!".

    Here's the code of the popup window

    HTML Code: 
    Hope it helps?

    Ta.

    Freddie

  8. #8
    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: VBA Internet Explorer - Select Button *** HELP ***

    Hello Fediie,

    Gu dé? Since I can test anything directly because it is a secure site, I made a change to the code below so we can see what "w" is. The added code is in blue. Run this a let me know what it says.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    11-25-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: VBA Internet Explorer - Select Button *** HELP ***

    Hi Leith,

    Well, fingers crossed this is what was meant to happen! In the immediate window it prints the name of the window "Search ~ salesforce.com - Unlimited Edition" - and the code runs through to the Stop that you added.

    Ta

    Freddie
    Last edited by vbafreddie; 12-11-2014 at 06:11 PM. Reason: missed text out.

  10. #10
    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: VBA Internet Explorer - Select Button *** HELP ***

    Hello Freddie,

    What was the value of "x"?

  11. #11
    Registered User
    Join Date
    11-25-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: VBA Internet Explorer - Select Button *** HELP ***

    Hi Leith,

    Sorry - new to this

    x = IWebBrowser2

    Ta

    Freddie

  12. #12
    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: VBA Internet Explorer - Select Button *** HELP ***

    Hello Freddie,

    I have been answering phone calls. I will put some code together for you test.

  13. #13
    Registered User
    Join Date
    11-25-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: VBA Internet Explorer - Select Button *** HELP ***

    Hey Leith,

    No worries - i just appreciate the help!!

    Ta

    Freddie

  14. #14
    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: VBA Internet Explorer - Select Button *** HELP ***

    Hello Freddie,

    Give this a try. This will replace all the code in the "Main" module. The IWebBrower2 interface is used to create an interactive HTML document from the MSXML2 library.
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    11-25-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: VBA Internet Explorer - Select Button *** HELP ***

    Hi Leith,

    Just tried it, and it brings a run time 91 error (object variable not set) on "HTMLdoc = Nothing"

    Also, when it runs through the code (after i comment the above line out) it shows the msgbox - however, i have a feeling that it's linked to the HTMLdoc code.

    Please Login or Register  to view this content.
    Thanks again!

    Freddie

  16. #16
    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: VBA Internet Explorer - Select Button *** HELP ***

    Hello Freddie,

    Dògan! My typing has been bad all day.

    It should be...
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 12-11-2014 at 08:10 PM.

  17. #17
    Registered User
    Join Date
    11-25-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: VBA Internet Explorer - Select Button *** HELP ***

    Ah, no worries...

    That got it past that, but instead now it makes the msgbox appear:

    Please Login or Register  to view this content.

  18. #18
    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: VBA Internet Explorer - Select Button *** HELP ***

    Hello Freddie,

    If the macro works properly up to the message box then you can delete that part of the code.

  19. #19
    Registered User
    Join Date
    11-25-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: VBA Internet Explorer - Select Button *** HELP ***

    Done!

    It now throws up an error on this line .Open "GET", HTMLdoc.LocationURL, True

    Same error 91, Object variable or With block variable not set.

    Please Login or Register  to view this content.
    Ta

    Freddie

  20. #20
    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: VBA Internet Explorer - Select Button *** HELP ***

    Hello Freddie,

    In that case, Internet Explorer is not running. You will need to restart it and rerun the macro.

  21. #21
    Registered User
    Join Date
    11-25-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: VBA Internet Explorer - Select Button *** HELP ***

    Hi Leith,

    I closed IE down completely and restarted the macro. It pulled up the same error

    Sorry!

    Freddie

  22. #22
    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: VBA Internet Explorer - Select Button *** HELP ***

    Hello Freddie,

    What URL is currently in you navigation bar?

  23. #23
    Registered User
    Join Date
    11-25-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: VBA Internet Explorer - Select Button *** HELP ***

    Hi Leith,

    In the popup window it's - https://na6.salesforce.com/_ui/commo...lksrch=2315623

  24. #24
    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: VBA Internet Explorer - Select Button *** HELP ***

    Hello Freddie,

    Okay, you get a popup window before or after the macro runs?

  25. #25
    Registered User
    Join Date
    11-25-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: VBA Internet Explorer - Select Button *** HELP ***

    Hi Leith,

    It's during the macro, which is why i was trying to define it as "w".

    In the code it starts:

    Please Login or Register  to view this content.
    It click a button on the main page where the data entry starts, then opens a popup window.

    Then it waits to load the page and assigns the window to "w"

    Please Login or Register  to view this content.
    Thanks

    Freddie

  26. #26
    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: VBA Internet Explorer - Select Button *** HELP ***

    Hello Freddie,

    Then the macro is working fine up to this point and then you need to click a button on this pop up window?

  27. #27
    Registered User
    Join Date
    11-25-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: VBA Internet Explorer - Select Button *** HELP ***

    Hi Leith,

    Exactly. It seems to define absolutely fine and prints the window name in the Immediate window.

    I just then need to click on the radio button and go! button on the popup window.

    Ta

    Freddie

  28. #28
    Registered User
    Join Date
    11-25-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: VBA Internet Explorer - Select Button *** HELP ***

    Hi Leith,

    Would it be better if i did a screen share with you so you can see the whole process working?

    Thanks for everything so far!

    Freddie

  29. #29
    Registered User
    Join Date
    11-25-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    23

    Re: VBA Internet Explorer - Select Button *** HELP ***

    Hi Leith,

    I have managed to get it working using the following:

    Please Login or Register  to view this content.
    I am not sure it's the proper way of working through a sheet, but it certainly works - if you know of a neater or more methodical way then please feel free to let me know.

    Thanks again for all your help!
    Freddie

+ 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. Internet Explorer Subtmit button via VBA
    By Matty5894 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-16-2014, 01:01 PM
  2. VBA and Internet Explorer: Radio Button selection
    By amike402 in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 01-30-2014, 09:28 AM
  3. [SOLVED] How to toggle focus between INTERNET explorer window and WINDOWS explorer window using VBA
    By tnuis in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-08-2013, 03:29 PM
  4. Command button(SEARCH) to open windows explorer to select file
    By sameerk0286 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-23-2010, 09:38 AM
  5. Using internet explorer through VBA
    By bodis in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-04-2010, 05:47 AM

Tags for this Thread

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