matt-gilbert
Member
Hello. I have a workbook that I use to create a report for our client. It has 5 sheets and each sheet has it's own Data Connection (DC), 2 from Excel files, 3 from our company's proprietary software ie a .rpt connection. I have written a macro to filter each of these DCs, copy and paste visible data onto 5 new spreadsheets, delete original 5 DC sheets and then save as a new workbook in a different folder. What I am having trouble with is deleting the 5 DCs. I have tried the following 2 codes with no success;
and;
NB: My DCs are not connected at this point as I am not on the company network. Maybe this is why it is not working?
Any help would be appreciated. Thanks in advance.
Matt
Code:
Do While ActiveWorkbook.Connections.Count > 0
ActiveWorkbook.Connections.Item(ActiveWorkbook.Connections.Count).Delete
Loop
Code:
For Each cn In ThisWorkbook.Connections
cn.Delete
Next cn
Any help would be appreciated. Thanks in advance.
Matt