trying to click webpage button with vba

dfida

New Member
Joined
Jan 26, 2010
Messages
49
Hi All...Happy New Year!

I've searched around and cannot seem to find a solution to this issue...I've been able to use VBA to fill in the login and password text boxes, but can't figure out how to click the button underneath them.
Using the code below, I get the following error message:

Run-time error 91:
Object variable or with block variable not set

Here is my code:

Code:
objIE.document.getelementbyid("login").Value = "123456"
objIE.document.getelementbyid("password").Value = "abcdefg"
objIE.document.getelementbyid("submit").Click

Here is the HTML for the submit button:


HTML:
        ********>document.write("");*********>

Can anyone help? I'm sure I'm overlooking something obvious...








</PRE>
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Is submit actually the id of the button?

Are the controls located on some sort of login form?

If they are you could try this.
Code:
objIE.document.forms(0).submit

PS I don't think the HTML has posted properly on the board.
 
Upvote 0
Is submit actually the id of the button?

Are the controls located on some sort of login form?

If they are you could try this.
Code:
objIE.document.forms(0).submit

PS I don't think the HTML has posted properly on the board.


Norie, about the login form, I think you are right. Using the following code, I was able to click and login just fine:

Code:
objIE.document.LoginForm.Submit.Click

However, even after login, I get the following error message:

run-time error 438
object doesn't support this property or method

So, now that I am actually able to login, I just need to get past this latest error so that I can go to the next step, which is to navigate to a URL. Is there code I can use to just ignore the error? Or is there a better way?


As for the HTML code not posting correctly, it looked ok in the preview, but when I click "submit reply" it posts differently. So, sorry about that. I still have not been able to get it to post correctly....attached is an image.
Capture-vi.png
 
Upvote 0
Ok, I figured it out. All I had to do was omit that last "Click" from my VBA.

Thanks for your help!
 
Upvote 0
There was no Click in the code I posted.

Don't think you can click a form, even if you can don't think it does much.:)
 
Upvote 0
There was no Click in the code I posted.

Don't think you can click a form, even if you can don't think it does much.:)

Norie....when you're a beginner like me, you tend to overlook those little details :laugh:

Thanks again for your help!
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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