• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA to open webpage then submit data

Frost101

New Member
I am very new to IE controlled by vba, but have stumbled by to write the following code, which was pieced together using various online searches.
My issue is that while this code works if a breakpoint is added before the 'click/submit' is clicked (then going to the IE window), it does not seem to update the webpage when it is run without a breakpoint.
If I were to break the code and see where the cursor is on the webpage, then resume the code, it will save and update but i can't seem to get it working normally.
Any help is much appreciated.

Code:
Sub test()
url = "Sharepoint - hidden"

Set IE = New InternetExplorerMedium
    IE.Visible = True
    IE.Navigate url
    
    
Dim HTMLDOC As HTMLDocument

Dim MyHTML_Element As IHTMLElement
Do
Loop Until IE.ReadyState = READYSTATE_COMPLETE

Set HTMLDOC = IE.Document


HTMLDOC.all.Item("ctl00_ctl40_g_07433f93_b974_4a29_9e53_cc3a087aa20a_FormControl0_V1_I1_T5").innerText = "New Employee - Test:" & Now()   '[Request Type]
HTMLDOC.all.Item("ctl00_ctl40_g_07433f93_b974_4a29_9e53_cc3a087aa20a_FormControl0_V1_I1_T5").Focus
HTMLDOC.all.Item("ctl00_ctl40_g_07433f93_b974_4a29_9e53_cc3a087aa20a_FormControl0_V1_I1_B3").Click
End sub
 
So the VBA procedure needs to be synchronized with the webpage as you can see in forums samples like in this very recent one :​
 
Back
Top