Macro to open IE tab

dodds

New Member
Joined
Oct 25, 2009
Messages
8
Hi there, I have the below macro to open webpages and automatically log in for a number of sites however i am struggling to work out how to get the pages to open in a new IE tab rather than in a new window, my browser is set to open links from other programmes in a new tab which works when I click on a hyperlink on my workbook but I cannot work out how to alter the macro to do the same as what the hyperlinks do.
Many thanks in advance

Public Sub Google()
Const strURL_c As String = "http://mail.google.com"
Const strUsr_c As String = ""
Const strPwd_c As String = ""
Dim objIE As SHDocVw.InternetExplorer
Dim ieDoc As MSHTML.HTMLDocument
Dim tbxPwdFld As MSHTML.HTMLInputElement
Dim tbxUsrFld As MSHTML.HTMLInputElement
Dim btnSubmit As MSHTML.HTMLInputElement
On Error GoTo Err_Hnd
'Create Internet Explorer Object
Set objIE = New SHDocVw.InternetExplorer
'Navigate the URL
objIE.navigate strURL_c
'Wait for page to load
Do Until objIE.readyState = READYSTATE_COMPLETE: Loop
'Get document object
Set ieDoc = objIE.document
'Get username/password fields and submit button.
Set tbxPwdFld = ieDoc.all.Item("Passwd")
Set tbxUsrFld = ieDoc.all.Item("Email")
Set btnSubmit = ieDoc.all.Item("signIn")
'Fill Fields
tbxUsrFld.Value = Worksheets("Login Data").Range("C12").Value
tbxPwdFld.Value = Worksheets("Login Data").Range("D12").Value
'Click submit
btnSubmit.Click
'Wait for page to load
Do Until objIE.readyState = READYSTATE_COMPLETE: Loop
Err_Hnd: '(Fail gracefully)
objIE.Visible = True
End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,214,810
Messages
6,121,690
Members
449,048
Latest member
81jamesacct

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