PDA

View Full Version : How can I refresh a webpage in VBA before downloading it?



roxnoxsox
05-17-2016, 03:31 AM
I have a series of webpages which I'm downloading into excel, and then manipulating through various formulas to obtain required data. This is all macro recorded, so in order to obtain new data every day, I just run the macro.

However, a few of these webpages are now not working. The date on the webpage will show as 13/05/2016 and when I run my macro, it downloads 13/05/2016. However, if I manually refresh the webpage, this will then update to 16/05/2016? Is there any line I can put into my macro which will automatically refresh the webpage for me before downloading into excel? Otherwise, I have to go into each webpage every day, click refresh, then go back into excel and run the macro? I hope this makes sense, I'm not good at explaining..

Please see example below:


Range("P25").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.mangold.se/MangoldOnline/produktinformation/SE0007439450.htm", _
Destination:=Range("$P$25"))
.Name = "SE0007439450"
.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