Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Auto Open file VBA Refresh MS Query Save Close


I have made a MS Query in Excel that queries a DB and puts the info int
excel. Is there code so that if I schedule the file to open the cod
will let the query to refresh and save and close the file?

Now we are having an employee open the file click enable auto refres
and save and close the file.

Thanks,
Greg
Impulse Manufacturin

--
gcutte
-----------------------------------------------------------------------
gcutter's Profile: http://www.excelforum.com/member.php...fo&userid=2751
View this thread: http://www.excelforum.com/showthread.php?threadid=47029

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Auto Open file VBA Refresh MS Query Save Close


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

  #3   Report Post  
Posted to microsoft.public.excel.programming
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


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
Unable to open after auto refresh(Query) Irmann Excel Discussion (Misc queries) 0 January 8th 08 06:33 AM
Auto Open, Refresh, Save, Close Jimmycooker Excel Discussion (Misc queries) 0 February 6th 06 01:34 PM
save & close after web query refresh JVLin Excel Discussion (Misc queries) 0 September 28th 05 04:27 PM
I like to open a folder,auto print,save then close tied of opening files Excel Programming 2 April 22nd 05 10:20 PM
Auto open 8 workbooks in different folders, then save on close... pkley[_2_] Excel Programming 0 October 11th 04 11:37 PM


All times are GMT +1. The time now is 11:54 PM.

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"