Hi Everyone,
I am creating a macro that should open a webpage and then take the value from a cell in Excelsheet and paste into a Text Box in a Webpage.
for time being am passing the cell value from code itself instead of taking from excelsheet. My initial step is to access the Tex tbox in the webpage. for that I took the ID of the text box.
Am getting "Run Time error 91 : Object variable or With block variable not set " on the line where i try to pass the value for the text box.
Sub VisitWebsite()
Const cURL = "http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Dim IE As InternetExplorer
Dim doc As HTMLDocument
Dim LoginForm As HTMLFormElement
Dim ContentID As HTMLInputElement
Dim HTMLelement As IHTMLElement
Set IE = New SHDocVw.InternetExplorer
IE.Visible = True
IE.navigate cURL
Do
Loop Until IE.readyState = READYSTATE_COMPLETE '= 4
Set doc = IE.Document
Set LoginForm = doc.forms(0)
Set ContentID = LoginForm.elements("dDocName")
ContentID.Value = "1234" ' Line where the error occurs "Run Time error 91 : Object variable or With block variable not set "
End Sub
The following is the HTML of that textbox
<tr>
<td align="right"><label for="dDocName"><span class="searchLabel">Content ID</span></label></td>
<td>
<input type="hidden" name="opSelected" value="hasAsSubstring">
<input type="text" size=30 id="dDocName"name="dDocName" value="" onKeyPress="checkForEnter(event)">
</td>
</tr>
am i taking the correct ID of that textbox?
Please help me to overcome this error.
Bookmarks