Not able to avoid warning message

renatoab

New Member
Joined
Jun 14, 2009
Messages
32
Hi

I'm running a macro that gets a file from the internet. My code is like this: (i got it recording the macro)

Code:
With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;https:// here my url..." _
        , Destination:=Sheets("mysheet").Range("$A$1"))


        .Name = "the name here"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = False
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = False
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 850
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = False
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileOtherDelimiter = "},{"
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
        
    End With

It works most of the time, but sometimes seems that the file is not available, and I get a warning message, and the macro stops. I want to treat this and avoid warning message, but nothing works.

I tried
Application.DisplayAlerts = False
also
On Error Resume Next
On Error goto somewhere


but it always show the warning message that the file was not found, and my macro stops.

Is there anything else to do in order to avoid the message?

Thank you
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
With On Error Resume Next, I can suppress the message (as it should do):

Code:
Sub test()

    On Error Resume Next
    
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;https:// here my url..." _
        , Destination:=Sheets("mysheet").Range("$A$1"))




        .Name = "the name here"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = False
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = False
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 850
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = False
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileOtherDelimiter = "},{"
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
        
    End With


End Sub
 
Upvote 0
That would probably happen. Because the error would be probably other.
But, as I said, my code is like this, but not exactly this. There is a url and a name field.
I`ve tried some solutions, like testing if url exists before that command. It seems to help, but I`m not sure yet.
I`d appreciate other solutions.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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