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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,280
Office Version
  1. 365
Platform
  1. Windows
Liam

Does the posted code not work?

It looks OK to me.
 

liambuchanan

New Member
Joined
Oct 10, 2018
Messages
4
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.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,280
Office Version
  1. 365
Platform
  1. Windows
Where in the code do you get the error?
 

liambuchanan

New Member
Joined
Oct 10, 2018
Messages
4

ADVERTISEMENT

On the very last line of the script

Code:
 ieDoc.getElementsByTagName("TR")(0).getElementsByClassName("menubutton")(0).Click
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,280
Office Version
  1. 365
Platform
  1. Windows
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
 

liambuchanan

New Member
Joined
Oct 10, 2018
Messages
4
Just tried that, get a new error code:

Run-time error '91':

Object variable or With block variable not set
 

Watch MrExcel Video

Forum statistics

Threads
1,129,557
Messages
5,637,043
Members
416,955
Latest member
Gohar hussain

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
Top