Run-Time Error '424': Object Required

JennaR

New Member
Joined
Feb 8, 2015
Messages
22
I am having a problem with a particular section of code in a project I'm working on. The total code for the Sheet is extensive, so I'm only posting the small bit that's relevant to the problem at hand.

The goal is to copy a particular cell, call a particular *already running* Internet Explorer window (there are generally three different instances of IE running at any given time), find the proper text box that the cell's information goes in (the Account Number field), and fill the textbox with the information from the clipboard. Ideally the macro would then click the submit button, but I'll cross that bridge when I come to it. When the designated trigger cell is clicked, my macro works perfectly at copying the information cell and calling the proper window.

However, it continually gives me an Object Required error and highlights the line below that I marked. I have tried numerous formats of code for that line, some short, some long, some simple, some extensive. No matter what I do, I keep coming back to the same error. I could be wrong, but I was sure that "pan" is the proper name for the box I need, but I guess I could be wrong. Out of 1500 lines of source code, I'm pretty sure I copied the relevant portion.

This is probably a simple error on my part, but it's been vexing me for days. Any help would be greatly appreciated.

Relevant VBA Code:

If Target.Address = "$N$1:$O$1" Then
Range("$C$1").Copy
AppActivate ("Proprietary Window Name")
IE.document.all("pan").Value = "4"<--------PROBLEM LINE
End If


Relevant Page Source Code:

</< font>td>
<tdcolspan="3" height="75" >
<tableborder="0" cellspacing="0" cellpadding="0" width="100%" height="100%" role="presentation" >
<trheight="40%" valign="bottom">
<tdwidth="5%"> </< font>td>
<tdcolspan="2" align='left' >
<labelfor="pan"><spanclass="BodyText">Account Number:</< font>span><label>
</< font>td>
</< font>tr>
<trvalign="top">
tdwidth="5%"> </< font>td>
<tdwidth="30%" valign="top" height="50%" align='left' >
<inputtype="text" maxlength="16" name="pan" id="pan" value="">
</< font>td>
<tdalign='left' valign="top">
<span> </< font>span>
<inputtype="button" name="button_get_trx_list_by_pan" value="Go" *******="javascript:NewSubmitForm('get_pan');">
</< font>td>
</< font>tr>
</< font>table>
</< font>td>
 
Is there perhaps a different way to call the active window than "AppActivate" that I'm just not familiar with?
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
IE.document.all("pan").Value = "4"<--------PROBLEM LINE

<inputtype="text" maxlength="16" name="pan" id="pan" value="">
<!--< font-->
Try
Code:
IE.document.all("pan")(0).Value = "4"
assuming it is the first element with name = "pan".

Or better:
Code:
IE.document.getElementById("pan").Value = "4"
One possible cause of the error is that the page uses frames and the element you're trying to reference sits inside in a frame. If so, you have to reference the element within the document within the frame - search this forum for example code.
 
Upvote 0

Forum statistics

Threads
1,215,526
Messages
6,125,329
Members
449,218
Latest member
Excel Master

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