View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default MS Query "Connections"

You may add this to your macro to delete the names before/after your fetch.

For Each Name In Sheets("Data").Names
Name.Delete
Next Name
========
or use a refresh like this with variable interspersed.

With sheets("sheet1").QueryTables(1)
.Connection = _
"URL;http://www.speedtv.com/schedule/index.php?m=&do=&week=" & X &
"&ts=&wholeMonth=&subcat=&program=&usecal=yes&star tMonday=1"
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingAll
.WebTables = "1,""speedListing"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
=======
or

Sub GP()
With Sheets("sheet1").QueryTables(1)
.Connection = _
"URL;http://postcalc.usps.gov/MailServices.aspx?Country=Domestic&M="
& [mytype] & "&P=0&O=" & [myounces] & "&OZ=78734&DZ=78731"
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
--
Don Guillett
SalesAid Software

"Johnslg" wrote in message
...
I have a sheet that lets the user enter a chart of accounts in a column &
then a macro runs against each account (using QueryTable), hits an SQL
database, and returns data. My problem is that it adds a new connection
each
time the mcro runs. I just deleted about 400 connections.

Is there a way to reuse the same connection (it's all going against the
same
server/database) or is there a way to automatically delete connetions?

Thanks.