Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Terminating Excel

Hi, from which external application are you trying to close the object, how
are you doing it and what is the error you are getting.

"newbie in hell" wrote:

I opened Excel, created an Excel file, save it, and close it by using
automation.
But when I try to close the Object (from an external application) I get an
Error.

Any ideas?

----- before this 8 sheets where created for the workbook----
'it Creates events
appExcel.VBE.MainWindow.Visible = False
With appExcel.Workbooks(1).VBProject.VBComponents("This Workbook").CodeModule
StartLine = .CreateEventProc("Open", "Workbook") + 1
.InsertLines StartLine, "ActiveWindow.SelectedSheets.PrintPreview" &
Chr(13) & "ThisWorkbook.Close" & Chr(13) ' "Application.Workbooks.Close" &
Chr(13) & "Application.Quit" & Chr(13) '& "ThisWorkbook.Close" & Chr(13) &
"WorkBooks.Exit" & Chr(13) '& "ThisWorkbook.Close" & Chr(13) &
"WorkBooks.Exit" & Chr(13)

StartLine = .CreateEventProc("BeforeClose", "Workbook") + 1
.InsertLines StartLine, "Application.Workbooks.Close" & Chr(13) &
"Application.Quit" & Chr(13) '& "ThisWorkbook.Close" & Chr(13) &
"WorkBooks.Exit" & Chr(13)

End With

appExcel.VBE.MainWindow.Visible = False
dummy% = DoEvents()
'VBCodeMod.InsertLines 1, "Sub Auto_open()" & Chr(13) &
"ActiveWindow.SelectedSheets.PrintPreview" & Chr(13) & "ThisWorkbook.Close" &
Chr(13) & "End Sub"

If Trim(Dir(strWorkDir_p & "af1xpt.cht", vbArchive)) < "" Then Kill
strWorkDir_p & "af1xpt.cht"
strContraseƱa_t = CStr(CDec(Rnd * 1E+15))

appExcel.Workbooks(1).SaveAs "C:\MyFile.xls", xlNormal_t
appExcel.Workbooks(1).Save
appExcel.Workbooks(1).Close
appExcel.VBE.MainWindow.Visible = False
appExcel.Workbooks.Close
appExcel.quit
Set appExcel = Nothing

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
terminating remote links? Jacob Excel Programming 1 November 10th 06 04:07 PM
Ensuring Excel start macros complete before terminating karlman Excel Programming 3 February 7th 06 11:42 PM
excel.exe is not terminating from task manager Inthi Excel Programming 0 November 28th 05 01:39 PM
Mysteriously terminating code [email protected] Excel Programming 6 August 2nd 05 03:22 PM
Terminating Forms S. L. S. Excel Programming 1 April 21st 05 10:50 PM


All times are GMT +1. The time now is 07:41 AM.

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"