![]() |
auto close in Excel 2007
I have the following code to auto close the workbook, but it does not work.
Any suggestions? Thanks for any assistance. Sub Auto_Close() ' ' Auto_Close Macro ' With ActiveWorkbook .RunAutoMacros xlAutoClose .Close End With ' End Sub |
auto close in Excel 2007
AUTO_CLOSE is designe dto run when you try to close the workbook...similarly
AUTO_OPEN only runs when you open a workbook yuo need some other event, eg using the ONTIME method SUB StartShutdown() Application.ONTIME TimeValue("17:00:00") , "shutdown" END SUB SUB shutdown() thisworkbook.SAVED=TRUE Thisworkbook.close false application.exit END SUB "jim" wrote: I have the following code to auto close the workbook, but it does not work. Any suggestions? Thanks for any assistance. Sub Auto_Close() ' ' Auto_Close Macro ' With ActiveWorkbook .RunAutoMacros xlAutoClose .Close End With ' End Sub |
auto close in Excel 2007
After thinking about it, that would make sense. Would there be any other
manner to close a workbook automatically, other than using the ONTIME function? This workbook organizes data so the data can be exported to another application, so what I'm trying to accomplish is having Excel do its majic and close, whereby no operator has to open it, run the necessary macros and then close it. "Patrick Molloy" wrote: AUTO_CLOSE is designe dto run when you try to close the workbook...similarly AUTO_OPEN only runs when you open a workbook yuo need some other event, eg using the ONTIME method SUB StartShutdown() Application.ONTIME TimeValue("17:00:00") , "shutdown" END SUB SUB shutdown() thisworkbook.SAVED=TRUE Thisworkbook.close false application.exit END SUB "jim" wrote: I have the following code to auto close the workbook, but it does not work. Any suggestions? Thanks for any assistance. Sub Auto_Close() ' ' Auto_Close Macro ' With ActiveWorkbook .RunAutoMacros xlAutoClose .Close End With ' End Sub |
auto close in Excel 2007
Patrick, I used your suggestion but it still does not close. The language
follows: Sub Auto_Open() ' ' M_Import_Telefile Macro ' ' Workbooks.OpenText Filename:="I:\telefile_import.txt", Origin _ :=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote _ , ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=True _ , Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), _ Array(3, 1)), TrailingMinusNumbers:=True ActiveWindow.Close End Sub Sub StartShutdown() Application.OnTime TimeValue("00:00:02"), "shutdown" End Sub Sub shutdown() ThisWorkbook.Saved = True ThisWorkbook.Close = False Application.exit End Sub "jim" wrote: After thinking about it, that would make sense. Would there be any other manner to close a workbook automatically, other than using the ONTIME function? This workbook organizes data so the data can be exported to another application, so what I'm trying to accomplish is having Excel do its majic and close, whereby no operator has to open it, run the necessary macros and then close it. "Patrick Molloy" wrote: AUTO_CLOSE is designe dto run when you try to close the workbook...similarly AUTO_OPEN only runs when you open a workbook yuo need some other event, eg using the ONTIME method SUB StartShutdown() Application.ONTIME TimeValue("17:00:00") , "shutdown" END SUB SUB shutdown() thisworkbook.SAVED=TRUE Thisworkbook.close false application.exit END SUB "jim" wrote: I have the following code to auto close the workbook, but it does not work. Any suggestions? Thanks for any assistance. Sub Auto_Close() ' ' Auto_Close Macro ' With ActiveWorkbook .RunAutoMacros xlAutoClose .Close End With ' End Sub |
auto close in Excel 2007
You could try...
sub CloseMe with thisworkbook .saved = true ' use this to discard any changes .save ' use this to save any changes without prompting 'and use neither if you want to be prompted in the normal way .close end with end sub change thisworkbook to activeworkbook if you want it close whichever is active at the time, and don't forget to save the book as a macro-enabled workbook - but you knew that M On Wed, 26 Nov 2008 09:43:01 -0800, jim wrote: I have the following code to auto close the workbook, but it does not work. Any suggestions? Thanks for any assistance. Sub Auto_Close() ' ' Auto_Close Macro ' With ActiveWorkbook .RunAutoMacros xlAutoClose .Close End With ' End Sub |
All times are GMT +1. The time now is 03:40 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com