VBA - Click menu button in Frame

liambuchanan

New Member
Joined
Oct 10, 2018
Messages
4
Good Afternoon,

I am new to this forum and also very new to VBA. For the past few weeks I have been trying to automate pulling data from a company webpage with no luck.

I have got as far as logging on to the webpage, navigating a dealer select drop down and onto the main dashboard. The bit i am facing an issue with is selecting the "MDP Performance" button which is in a frame.

Here is the VBA script I have right now:

Code:
Sub Test()

Dim ieApp As InternetExplorer
Dim ieDoc As Object
Dim html As HTMLDocument
Dim frame As HTMLFrameElement
Dim img As HTMLImg


Set ieApp = New InternetExplorerMedium


ieApp.Visible = True


ieApp.navigate "https://www.motabilityonline.co.uk/IdM/login"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.readyState = READYSTATE_COMPLETE: DoEvents: Loop


Set ieDoc = ieApp.document


With ieDoc.forms(0)
.UserName.Value = "USERNAME"
.Password.Value = "PASSWORD"
.submit
End With
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.readyState = READYSTATE_COMPLETE: DoEvents: Loop


Set ieDoc = ieApp.document


With ieDoc.forms(0)
.organisationSelection.Value = "2005"
.submit
End With
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.readyState = READYSTATE_COMPLETE: DoEvents: Loop


ieApp.navigate "http://www.motabilityonline.co.uk/OLA/"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.readyState = READYSTATE_COMPLETE: DoEvents: Loop


Set ieDoc = ieApp.document.frames("menu").document
    ieDoc.getElementsByTagName("TR")(0).getElementsByClassName("menubutton")(0).Click
    
End Sub

Frame Script:

HTML:
<FRAME noResize src="mainMenu.jsp" name=menu scrolling=no>

and here is the menu/button script:

HTML:
<TR><TD class=menupad><TABLE class=menubutton cellSpacing=0 cellPadding=0 border=0><TBODY><TR><TD id=menu_134><A class=menubuttontext style="CURSOR: pointer" href="/OLA/mdpDashboard/secure/pageSelect.do?forward=view" target=body>MDP Performance</A> </TD></TR></TBODY></TABLE></TD></TR>


Apologies if the above information isnt what is needed!

Many Thanks,

Liam
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Liam

Does the posted code not work?

It looks OK to me.
 
Upvote 0
Hi Norie,

Thanks for the quick response,

Unfortuantly not, forgot to post this into the orginal question:

I get the code:

Run-time error '-2147352319 (80020101)':

Method 'frames' of object 'JScriptTypeInfo' failed.
 
Upvote 0
Where in the code do you get the error?
 
Upvote 0
On the very last line of the script

Code:
 ieDoc.getElementsByTagName("TR")(0).getElementsByClassName("menubutton")(0).Click
 
Upvote 0
What happens if you try submitting the form within the frame as you do early in the code for the main page?
Code:
Set ieDoc = ieApp.document.frames("menu").document
ieDoc.forms(0).submit
 
Upvote 0

Forum statistics

Threads
1,213,561
Messages
6,114,315
Members
448,564
Latest member
ED38

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