+ Reply to Thread
Results 1 to 5 of 5

Removing connections

Hybrid View

Amdi Removing connections 01-28-2013, 08:53 AM
OllieB Re: Removing connections 01-28-2013, 09:22 AM
Amdi Re: Removing connections 01-28-2013, 09:41 AM
OllieB Re: Removing connections 01-28-2013, 09:45 AM
Amdi Re: Removing connections 01-30-2013, 06:05 AM
  1. #1
    Registered User
    Join Date
    09-21-2012
    Location
    Esbjerg, denmark
    MS-Off Ver
    Excel 2007
    Posts
    3

    Removing connections

    Hi All,

    I am writing a macro that collects data from many different http addresses on our intranet. This however leaves me with a lot of connections, that slows excel after a while. How can I delete these connections ? I create the connection as shown below.

    With ActiveSheet.QueryTables.Add(Connection:= _
                "URL;http://pdm:8080/lm/Forms/matdb/laminate?laminate=" & TempCertificate, Destination:= _
                Range("$A$2"))
                .Name = "Connection"
                .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

    I have tried "
    ActiveWorkbook.Connections("Connection").Delete
    " with no effect.
    Last edited by Amdi; 01-28-2013 at 09:40 AM.

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Removing connections

    Hi Amdi,

    The forum rules stipulate that if you show code in your post you must do so using CODE tags. Please edit you post, select the code and click on the # button.
    If you like my contribution click the star icon!

  3. #3
    Registered User
    Join Date
    09-21-2012
    Location
    Esbjerg, denmark
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Removing connections

    Sorry about that. It has been corrected.

  4. #4
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Removing connections

    Hi Amdi,

    No probs.

    Try deleting the QueryTable as opposed to the connection

  5. #5
    Registered User
    Join Date
    09-21-2012
    Location
    Esbjerg, denmark
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Removing connections

    Hi OllieB

    Thanks, that worked. with your advice and a little help from google I found the below to remove the tables.

    Sub DeleteAllQueries()
    
         Dim qt As QueryTable
         Dim WSh As Worksheet
    
         For Each WSh In ThisWorkbook.Worksheets
              For Each qt In WSh.QueryTables
                   qt.Delete
              Next qt
         Next WSh
    
    End Sub
    I also stumbled over the method below, that also can solve this issue.

    For Each cn In ThisWorkBook.Connections
        cn.Delete
    'Next cn

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1