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
|