Enter data to web page with VBA

hstaubyn

Board Regular
Joined
Sep 13, 2010
Messages
93
Hi,

I am trying to fill a text box on a web page with discouraging results.

When I try to trun the code below, I get a Run time error '91' - "Object Variable or With Block Variable not set" and when I click 'Debug', the last line of code (with "Hello" in it) is highlighted.

Code:
 Sub Fill_Website_Textbox()
Dim objIE As SHDocVw.InternetExplorer
Dim OrgBox As HTMLInputElement
 
Set objIE = New SHDocVw.InternetExplorer
objIE.Navigate "My Website"
    objIE.Visible = True
    WaitReady 'Sub to wait while internet loads
 
Set OrgBox = objIE.Document.getElementById("ctl00_MainContent_TabContainer_ProjectInformationPanel_ProjectListView_ctrl0_websiteTextBox")
[COLOR=red]OrgBox.Value = "Hello"[/COLOR]
 
End Sub

This is not the complete code, just the important bit. The website loads fine, but when it gets to the entering data part, the error crops up. Can anyone tell me where I'm going wrong?

Thanks,
H
 
Can you post the URL?

Without that it's almost impossible to help.
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I know this is an old thread, and I may be hijacking but it seemed appropriate to continue the thread rather than create a new one.

My dilemma is similar to OP, in which I am attempting to create a macro in order to hyperlink and automatically input data from a cell into a search box. This is for my job at my company which I will retain it's anonymity (mostly, minus my IP). I am trying to create an excel spreadsheet that lists a few hundred documents (they each have a document number with formatting such as "WXX-XXX-XXX" or "IP-XXX-XXX") and then when they click the document they are interested in-- it forwards them to our company's intranet page search engine and automatically inputs the name and additional criteria they may need. A little background about this project, I'm an Engineering Intern that is attempting to improve the end-user ease of use with our deeply rooted (and poorly structured) corporate documentation system. Due to our documents having revisions almost MONTHLY, federal law states we must always use up-to-date documentation. This is why it is critical that they search it through intranet, however the documents used to reference specific revisions don't exist because their references would have to be updated every time as well! Which is why I'm creating an unofficial generic search spreadsheet to find these files internally.

My question is: Where do I start? I've seen how to input data into a webpage like google using a macro. But google only has one input bar.
I'd post a screenshot but apparently tinypic.com has banned my work's IP AND apparently copying and pasting the form-search works??? Odd. I am a fast learner with code, I'm an expert with MATLAB and amateur with C/C++ (haven't had many times where I've been forced to use it). This will be my first project in excel macros but I'm willing to bite off a lot to get this done. Here is how the search form looks:

On-Line
Inserts

No. Of Records Per
Page:
<select id="DropDownList1" name="DropDownList1"> <option value="10">10</option> <option value="20">20</option> <option selected="" value="50">50</option> <option value="100">100</option> <option value="200">200</option> <option value="500">500</option></select>
Item Number:
<input id="TextBox1" name="TextBox1" maxLength="30"> <input id="Button1" name="Button1" value="Submit" type="submit">
Revision:
<input id="TextBox2" name="TextBox2" maxLength="2" size="2">
Description:
<input id="TextBox3" name="TextBox3" size="30">

<tbody>
</tbody>
Full Text Search

<tbody>
</tbody>


My main question is: Is this possible? According to OP, it is possible.
When I use the "google" search macro, it simply fills in the URL with your search criteria:
i.e. - When I search "this is my search criteria" it is placed into the url
h-t-t-p-s://www.google . com/?gws_rd=ssl#q=this+is+my+search+criteria

When I search this in my intranet form it does not show. The url remains the same but the contents show up on the page correctly.
i.e. - Search "Item Number: W55-000-765"
h-t-t-p-s://home. *********** . com/oracle3/manuals_inserts.aspx?sDocType=insert

(I added dashes in the url to avoid making an actual hyperlink, I don't want anyone thinking I'm spamming).
If anyone can explain this to me (fairly technically) that would be great! haha
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,977
Members
449,200
Latest member
Jamil ahmed

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top