I am trying to copy two worksheets to a new workbook and rename/save that new workbook.
When I copy the worksheets over - the queries are copying with it...which is causing issues when I try to save the new workbook. To get around this, I am having to delete the queries / connections...then save it. In the code below, it is deleting the queries and connections in both worksheets and saving both worksheets. I don't want to delete queries in the 'source' workbook...only the new workbook. (or not copy them at all!)
Prive Sub NewBook()
With ActiveWorkbook
Dim FileName As String
FileName = [insert_file_name]
Dim cn As WorkbookConnection
Dim qr As WorkbookQuery
On Error Resume Next
For Each cn In ThisWorkbook.Connections
When I copy the worksheets over - the queries are copying with it...which is causing issues when I try to save the new workbook. To get around this, I am having to delete the queries / connections...then save it. In the code below, it is deleting the queries and connections in both worksheets and saving both worksheets. I don't want to delete queries in the 'source' workbook...only the new workbook. (or not copy them at all!)
Prive Sub NewBook()
With ActiveWorkbook
Dim FileName As String
FileName = [insert_file_name]
Dim cn As WorkbookConnection
Dim qr As WorkbookQuery
On Error Resume Next
For Each cn In ThisWorkbook.Connections