Terminating IE connection when server not responding

DLW1

New Member
Joined
Mar 22, 2011
Messages
3
<TABLE class=tborder id=post2656268 cellSpacing=0 cellPadding=6 width="100%" align=center border=0><TBODY><TR vAlign=top><TD class=alt1 id=td_post_2656268 style="BORDER-RIGHT: #ffffff 1px solid">I am contacting the yahoo finance server to download a large group of historical stock quotes using VBA. Everything typically works fine but I occasionally get a message alert that says "Contacting Server" or "downloading". Once this happens for an extended time I lose control and the VBA code hangs. I must maually hit the escape key or cancel key to continue the program. How do I detect this alert automatically in VBA and terminate the internet connection so I can retry again? The application.displayalerts=False command does not suppress it. Thanks very much to anyone that can help. Here is the relevent part of my code:


For N = 1 To StockNum

Workbooks(SPfile).Activate
Name = Range("A" & N).Value
Symb = Range("B" & N).Value

On Error GoTo Err_Handler

Application.DisplayAlerts = False

Workbooks.Open ("http://ichart.finance.yahoo.com/table.csv?s=" & Symb & "&d=" & Month & "&e=" & Day & "&f=" & Year & "&g=d&a=9&b=6&c=2007&ignore=.csv") 'downloads yahoo data. This is the statement that sometimes hangs

Workbooks("table").Activate
Application.DisplayAlerts = True

Range("B2.G2").Activate 'Copies Daily table data into Master Stock File starting at row 3
Selection.Copy

Workbooks("MasterStockFile2").Worksheets("Daily").Activate
Range("c" & (N + 2)).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("a" & (N + 2)) = Name
Range("b" & (N + 2)) = Symb

Next N

<!-- / message --></TD></TR><TR><TD class=alt2 style="BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 0px solid; BORDER-LEFT: #ffffff 1px solid; BORDER-BOTTOM: #ffffff 1px solid">
user_online.gif
</TD><TD class=alt1 style="BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 0px solid; BORDER-LEFT: #ffffff 0px solid; BORDER-BOTTOM: #ffffff 1px solid" align=right><!-- controls --></TD></TR></TBODY></TABLE>
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,305
Messages
5,836,539
Members
430,436
Latest member
Emilycr

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
Top