Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default remove query table when saving

I am updating an excel spreadsheet with data from sage using Query. I am
than doing some calculation before e-mailing on, the problem I have is that
the file I am sending still has the refresh data command and can be linked to
the source data which I do not want. Is there some code that could uncheck
the "Save query definition" in data range properties or is there a simpler
way.

Any help would be greatly appreciated

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default remove query table when saving

Michael,

I was looking for exactly the same solution. This is what I ended up with;

Sub PrepareReport()
'
' PrepareReport Macro
' Macro recorded 8/09/2005 by Tige Brown
'

'
Dim Fname As String
Dim CrntDir As String
Dim SDate As String
Dim Wsheet As Worksheet
Dim qtb As QueryTable

SDate = Format(Year(Now), "0000") & "-" & Format(Month(Now), "00") & "-"
& Format(Day(Now), "00")

Fname = ActiveWorkbook.Path & "\Price List Audit " & SDate

ActiveWorkbook.SaveAs Filename:=Fname, FileFormat:=xlNormal,
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

For Each Wsheet In ActiveWorkbook.Worksheets

For Each qtb In Wsheet.QueryTables
qtb.Delete
Next

Next

ActiveWorkbook.Save

Active

End Sub


And it works fine. Got the solution from the following forum;

http://www.excelforum.com/archive/in.../t-332827.html

Tige

"Michael" wrote:

I am updating an excel spreadsheet with data from sage using Query. I am
than doing some calculation before e-mailing on, the problem I have is that
the file I am sending still has the refresh data command and can be linked to
the source data which I do not want. Is there some code that could uncheck
the "Save query definition" in data range properties or is there a simpler
way.

Any help would be greatly appreciated

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 233
Default remove query table when saving

VBA code:

Myworksheet.QueryTables("my_query").EnableRefresh = False

should do the trick

I would suggest creating a copy of the workbook first, else *you* wont
be able to refresh the table as well.

DM Unseen

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default remove query table when saving

Absolutely fantastic, thanks

Michael

"Tige" wrote:

Michael,

I was looking for exactly the same solution. This is what I ended up with;

Sub PrepareReport()
'
' PrepareReport Macro
' Macro recorded 8/09/2005 by Tige Brown
'

'
Dim Fname As String
Dim CrntDir As String
Dim SDate As String
Dim Wsheet As Worksheet
Dim qtb As QueryTable

SDate = Format(Year(Now), "0000") & "-" & Format(Month(Now), "00") & "-"
& Format(Day(Now), "00")

Fname = ActiveWorkbook.Path & "\Price List Audit " & SDate

ActiveWorkbook.SaveAs Filename:=Fname, FileFormat:=xlNormal,
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

For Each Wsheet In ActiveWorkbook.Worksheets

For Each qtb In Wsheet.QueryTables
qtb.Delete
Next

Next

ActiveWorkbook.Save

Active

End Sub


And it works fine. Got the solution from the following forum;

http://www.excelforum.com/archive/in.../t-332827.html

Tige

"Michael" wrote:

I am updating an excel spreadsheet with data from sage using Query. I am
than doing some calculation before e-mailing on, the problem I have is that
the file I am sending still has the refresh data command and can be linked to
the source data which I do not want. Is there some code that could uncheck
the "Save query definition" in data range properties or is there a simpler
way.

Any help would be greatly appreciated

Thanks

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems saving pivot table in same workbook as export query mcaronna Charts and Charting in Excel 0 March 1st 07 06:03 PM
Remove content when saving / loading spreadsheet EZdoesIT Excel Worksheet Functions 4 November 13th 06 03:42 PM
Save data retreived from query without saving query Anthony Excel Discussion (Misc queries) 0 January 25th 06 07:17 PM
VB way to remove the query from a Query Table? Toby Erkson[_3_] Excel Programming 4 October 29th 04 03:16 PM
Pivot Table SQL Query saving Xi Grix Excel Programming 0 August 15th 04 08:29 PM


All times are GMT +1. The time now is 02:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"