I have already created a Macro using a 3rd party application that does what i want 80% of the time. The problem is that i can’t leave it running because it sometimes bugs out, or the browser takes a little longer to respond.
I would like to know if i could create what i wanted in the macro manager that comes with excel (VBA).
I want to:
- copy from A1, go to browser, paste in text box 1 (about half way down the page)
- Go back to excel, copy from B1, go to browser, paste in text box 2
- Click button in browser that says “Add”
- Wait for pop up box (javascript alert) to disapear
- Rinse and repeat X times, this time from A2 and B2.
Can you help?
user1242345, there are two ways to go about it.
Way 1
You can launch the URL in WebBrowser1 from VBA and then write to the textbox directly using
.GetElementByIDFor example
WebBrowser1.Document.getElementById("TextBoxName").Value = "Whatever"Way 2
Use XMLHTTP. This is way much faster than Way 1
If you can share the link then I can give you an exact answer?
FOLLOWUP
I copied the source code in a text file and saved it as Test.Htm on my desktop. Please see the example below on how to write to the first textbox. i am sure you can replicate it for the next 😉
To run this, create a userform in Excel and place the WebBrowser1 control and a CommandButton Control in the form. See Snapshot.
SNAPSHOT 1
Paste this code in the code area of the userform.
When you click on the button the text gets auto populated as show below.
SNAPSHOT 2
MORE FOLLOWUP
I usually don’t post a solution in such a scenario but advise the Asker to learn VBA but since I have already posted a major chunk so I will finish it for you. But any more questions from you this point onwards has to be followed by the code that you have written yourself 🙂
UNTESTED
Try this
HTH
Sid