View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Vacation's Over Vacation's Over is offline
external usenet poster
 
Posts: 279
Default Auto Open file VBA Refresh MS Query Save Close

HEY, if you put worksheet.close code in teh worksheet open sub.......

The only way to open the file for viewing os to disable macros when asked at
open.

"Simon Murphy" wrote:


Greg
Try something like this (you'll have to change it for your setup -
easiest way will be to record a macro then refresh your query then stop
and paste the code)

put this in the 'ThisWorkbook' class module:

Private Sub Workbook_Open()
Sheet1.QueryTables(1).Refresh
Me.Save
Me.Close savechanges:=False
End Sub

note the workbook closes before the code finishes which isn't very
elegant, but it gets the job done.


cheers
Simon


--
Simon Murphy
------------------------------------------------------------------------
Simon Murphy's Profile: http://www.excelforum.com/member.php...o&userid=26538
View this thread: http://www.excelforum.com/showthread...hreadid=470298