VBA Internet automation problem!

Major Nibbles

New Member
Joined
Aug 16, 2011
Messages
1
Hello all,

Long time reader, first time writter.

I have been using VBA for a few months now and have read thread upon thread of how to use html control for IE. I have managed to fill out two forms and press a submit button, however when I navigate to the webpage I need it seems impossible. I have tried everytype of command I have found online, It seems the only way now is to see if any of you guys could tell me what I seem to be doing wrong!

I am currently using this on my code to fill out the first two forms, click a button, then wait and click another button, this all works:

Code:
MSG2 = MsgBox("The Macro will begin after clicking OK. Please press NOTHING unless prompted by a pop up. If something looks to be going wrong. Click on the excel spreadsheet in the toolbar and press ESC. Some areas may seem slow, this is to allow exceptions in the system to pass.Please also ensure no Internet Explorer windows are open...Would you like to proceed?", vbYesNo, "Important")
If MSG2 = vbNo Then
  MsgBox "The macro will now end."
  Exit Sub
End If
manager = Worksheets("home").Cells(7, 3)
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = 1
apiShowWindow IE.hwnd, SW_MAXIMIZE
'Go to this Web Page!
IE.Navigate "[URL]http://btpeople.intra.bt.com/psp/PTPRD/EMPLOYEE/EMPL/e/?url=http%3a%2f%2fbtpeople.intra.bt.com%3a61050%2fpsc%2fHR9PRD01%2fEMPLOYEE%2fHRMS%2fc%2fROLE_MANAGER.EP_NP_REDIRECT_MGR.GBL&FolderPath=PORTAL_ROOT_OBJECT.BT_HCM_MSS_HOME_PAGES.HC_MSS_PERFORMANCE_MGMT.HC_EPMSS_MGR_NOTES_GBL&IsFolder=false&IgnoreParamTempl=FolderPath%2cIsFolder[/URL]"
Do Until IE.readyState = 4 '//4 = readystate_complete
Loop
IE.Visible = True
introwcount = Worksheets("workings").Cells(1, 10)
Application.WindowState = xlMaximized
Application.Visible = True
user = InputBox(Prompt:="Please enter your username.", _
          Title:="ENTER YOUR USERNAME", Default:="EIN")
pass = InputBox(Prompt:="Please enter your password.", _
          Title:="ENTER YOUR PASSWORD", Default:="Password")
Application.WindowState = xlMinimized
IE.Visible = True
IE.document.getElementById("USER").Value = user
IE.document.getElementById("PASSWORD").Value = pass
Dim i As Integer
Dim max As Integer
max = 25
For i = 0 To max
If IE.document.getElementsByTagName("input").Item(i).getAttribute("type") = "submit" Then
 IE.document.getElementsByTagName("input").Item(i).Click
Exit For
 End If
Next i
Application.Wait (Now + TimeValue("0:00:3"))
IE.document.forms(0).Item("Yes").Click
Do Until IE.readyState = 4 '//4 = readystate_complete
Loop

This now takes you to an intranet site, the HTML code of the button I want to push looks like this:
HTML:
<tr>
<td height='53'></td>
<td colspan='3' nowrap='nowrap'  valign='top' align='left'>
<input type='button' name='DERIVED_HR_NP_HR_NP_ADD_PB' id='DERIVED_HR_NP_HR_NP_ADD_PB' tabindex='37' value="Add a New Note"  class='PSPUSHBUTTON' style="width:132px; " *******="submitAction_win0(this.form,this.name);" />
</td>
</tr>


I have tried the previous ways with its name, tabindex and value, however none work.

Hope you can help

Thanks,

Paul

PS i have HTML object library and internet controls referenced already.
 
Last edited:

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,224,524
Messages
6,179,310
Members
452,906
Latest member
phanmemchatdakenhupviral

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