Hi,
I'm having difficulty with a web query that previously worked in older versions of Excel. In the past I was prompted for a username and password when running the web query and all would work fine.
Now when running the same code I'm presented with the error message:
Run-time error '1004':
Unable to open http://reg.bom.gov.au/products/reg/IDS65006.shtml
The hyperlink cannot be followed to the destination
And I am no longer prompted for a username/password.
I've tried inserting the username/password into the code (which has worked in older versions of Excel).
Sub Login_WebQuery()
Dim MyPost As String
Const MyUrl As String = "http://reg.bom.gov.au/products/reg/IDS65006.shtml"
Const PostUser As String = "login=xxxxx" 'Change user name here
Const PostPassword As String = "&pass=xxxxxx" 'Change password here
MyPost = PostUser & PostPassword
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & MyUrl, Destination:=Cells(1, 1))
.PostText = MyPost
.Name = "IDS65006.shtml"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
And removing the username/password and trying just a simple query
Sub qForecast()
'
'Query Forecast Data
'
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://reg.bom.gov.au/products/reg/IDS65006.shtml", Destination:=Range( _
"$A$1"))
.Name = "IDS65006.shtml"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
But to no avail - I'm still not prompted for a username/password.
If a go through the 'Build a Web Query' dialog I can get it to work for a little while. But after some time and a few query refreshes I start getting the same popup message as above. As the data requires reformating programatically after the refresh its not practical for the user the continue rebuilding the query from the dialog.
This is driving me nuts as I can't find much reference to it on the web. I think it could be a 2010 security issue where Office won't pass a username/password along to a website unless it's done over a SSL connection. I found a registry tweak but can't test it as I don't have Administrative rights on my PC.
Any other ideas - Thanks
Bookmarks