How to pass password

tropix100

New Member
Joined
May 7, 2011
Messages
9
Hey guys. I am a newbie here so pardon my ignorance.
I have a web connection wich works fine.
I also have some code to pass my user name and password to an opening page which works fine.
What doesnt happen is when passing my access to the opening page its doesnt give access to my web connection from which I imports a table.

I cannot determine how to have them work together to help me open up my ultimate page withing the connection.

Maybe Im looking at it all wrong and need a completely different approach. Thats why Im here.

Any help if appreciated.

Making the Web Connection:

Sub CreateTheConnection(PageNum As Integer)
Application.ScreenUpdating = False
Set QT = ActiveSheet.QueryTables.Add(Connection:="URL;MYURL?page= " & PageNum & "", Destination:=Range("$A$1"))
With QT
.Name = "Pass it up"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = """mov_table"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
If Range("$B$3").Value = "" Then
MsgBox PageNum
End
End If
End Sub


Passing my UserName and Password


Sub LoginToWebSite(URL As String)
Dim theItm As HTMLFormElement
Dim i As Integer
Set myIE = New InternetExplorer
With myIE
.Navigate URL
Do While .Busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop
End With
Set myIEdoc = myIE.Document
Set theForm = findFm(myIEdoc)
With theForm

On Error GoTo Errhandler

.Item(0).Value = "USERNAME"
.Item(1).Value = "MYPASSWORD"
End With
Application.SendKeys "{ENTER}", False

Errhandler:

Set myIE = Nothing
End Sub


The calls to the respective procedures are correct and work. It is all pretty standard code.
I have removed some of the code to simplify the procedures here. They work in this condition.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Try using PostText property:

E.g:
Code:
Sub CreateTheConnection(byval MyUrl as String)
Dim MyPost As String
Const PostUser As String = "login=User Name" 'Change user name here
Const PostPassword As String = "&pass=password" 'Change password here
    
MyPost = PostUser & PostPassword
    
With ActiveSheet.QueryTables.Add(Connection:= _
    "URL;" & MyUrl, Destination:=Cells(1, 1))
    .PostText = MyPost
    .BackgroundQuery = True
    .TablesOnlyFromHTML = True
    .Refresh BackgroundQuery:=False
    .SaveData = True
End With
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,220
Members
452,895
Latest member
BILLING GUY

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