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.
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.