Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim Jim is offline
external usenet poster
 
Posts: 615
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Jim is offline
external usenet poster
 
Posts: 615
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
Jim Jim is offline
external usenet poster
 
Posts: 615
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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



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
Can I stop the close method in an auto close macro Paul Excel Programming 2 November 17th 06 02:48 PM
Auto Excel workbook close: save= false during an auto subroutine tomwashere2 Excel Programming 10 June 16th 05 06:23 AM
Auto Close Excel Workbook MBlake[_2_] Excel Programming 2 June 2nd 05 09:44 PM
Run Auto Close when Excel Closes ben Excel Programming 0 October 1st 04 04:25 PM
Auto close excel without saving John Haywood Excel Programming 0 August 23rd 04 09:00 PM


All times are GMT +1. The time now is 02:15 PM.

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

About Us

"It's about Microsoft Excel"