Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to re-fresh the import links if it fails?

I would like to retry 5 times to retrieve data from import links if it fails
to be retrieved. Does anyone have any suggestions on how to refresh the
import links if it fails?
Thanks in advance for any suggestions
Eric
------------------------------------------------------------------------------------------
Dim qtEntry As QueryTable
Dim qryConnect As String
Dim anyRange As Range
Dim anySheet As Worksheet

Set anyRange = Sheets("1").Range("A1:" & _
Sheets("1").Range("A1").SpecialCells(xlLastCell).A ddress)
On Error Resume Next ' errors if no querytable entry
anyRange.QueryTable.Delete
On Error GoTo 0
anyRange.ClearContents

qryConnect = "URL;http://www.cnn.com"

Set anySheet = Sheets("1")
With anySheet.QueryTables.Add(Connection:=qryConnect, Destination _
:=anySheet.Range("$A$1"))

.Name = "Summary"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.Refresh BackgroundQuery:=False
End With

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default How to re-fresh the import links if it fails?

If I follow include something like this

With ....
' code
On Error Resume Next
' .Connection = "URL;http://www.cnn123456.com"

For i = 1 To 5
' If i = 5 Then
' .Connection = "URL;http://www.cnn.com"
' End If

.Refresh BackgroundQuery:=False
If Err.Number Then
Err.Clear
Else
Exit For
End If
Next
If i = 6 Then
Debug.Print "failed"
Else
Debug.Print i & " attempt(s) success"
End If

On Error GoTo 0
End With

uncomment the commented lines for testing

Regards,
Peter T

"Eric" wrote in message
...
I would like to retry 5 times to retrieve data from import links if it
fails
to be retrieved. Does anyone have any suggestions on how to refresh the
import links if it fails?
Thanks in advance for any suggestions
Eric
------------------------------------------------------------------------------------------
Dim qtEntry As QueryTable
Dim qryConnect As String
Dim anyRange As Range
Dim anySheet As Worksheet

Set anyRange = Sheets("1").Range("A1:" & _
Sheets("1").Range("A1").SpecialCells(xlLastCell).A ddress)
On Error Resume Next ' errors if no querytable entry
anyRange.QueryTable.Delete
On Error GoTo 0
anyRange.ClearContents

qryConnect = "URL;http://www.cnn.com"

Set anySheet = Sheets("1")
With anySheet.QueryTables.Add(Connection:=qryConnect, Destination _
:=anySheet.Range("$A$1"))

.Name = "Summary"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.Refresh BackgroundQuery:=False
End With



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hello, fresh here! HardenMassie Excel Worksheet Functions 0 August 24th 10 10:13 PM
Need a fresh pair of eyes ibvalentine Excel Worksheet Functions 11 May 3rd 09 11:33 PM
Fresh pair of Eyes required [email protected] Excel Worksheet Functions 4 March 17th 08 11:54 PM
fresh learner need help! Flamingo Excel Programming 2 July 12th 06 04:08 AM
macro only runs on fresh open of excel? Jake Marx[_2_] Excel Programming 0 September 19th 03 04:15 PM


All times are GMT +1. The time now is 06:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"