View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
maliaf maliaf is offline
external usenet poster
 
Posts: 4
Default Closing excel from a macro

I am currently opening excel from a java application. I use the excel object
(this workbook) to run several macros. The java application opens excel, so
every time excel is opened, some code must be run and then excel must be
close. The code I am trying to use is:

Private Sub Workbook_Open()
Macro1
tbmfile = "C:\excelfile.xls"
tbmxcelfile = "excelfile"
Windows(tbmxcelfile).Activate
ActiveWorkbook.Save
Application.Quit

If I step through this code it works fine and closes excel. But when I open
excelfile.xls from my documents, the macros are triggered to run, but excel
does not close. Why is that?