Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a code which automates few things to create an excel file. The
problem is that once its done and saves the file and closes it the excel process still is running in the background. It terminates it self after the app completely closes it's self. here is a pice of my code: ================================================== ===== xlApp.SetUserControl(false); xlApp.SetVisible(false); wb = xlApp.GetWorkbooks(); _wb = wb.Add(covOptional); ws = _wb.GetSheets(); //Automate some stuff... _wb.SetSaved(TRUE); _wb.SaveCopyAs(COleVariant(filePath)); _wb.Close(COleVariant(covFalse),COleVariant(filePa th),COleVariant((long)0)); wb.Close(); xlApp.Quit(); xlApp.ReleaseDispatch(); xlApp = NULL; wb = NULL; ws = NULL; _ws = NULL; _wb = NULL; so am I terminating these in the wrong order? I've tryed different ways... This class is called from button event. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Excel doesn't have a "SetSaved" property, but rather a "Saved" property on
the workbook. Therefore, the code may be erroring out prior to getting to the lines dealing with closing out the workbooks and app, depending on how you have the app setup to handle run-time errors. -- Sincerely, Ronald R. Dodge, Jr. Master MOUS 2000 "Kevin" wrote in message ups.com... I have a code which automates few things to create an excel file. The problem is that once its done and saves the file and closes it the excel process still is running in the background. It terminates it self after the app completely closes it's self. here is a pice of my code: ================================================== ===== xlApp.SetUserControl(false); xlApp.SetVisible(false); wb = xlApp.GetWorkbooks(); _wb = wb.Add(covOptional); ws = _wb.GetSheets(); //Automate some stuff... _wb.SetSaved(TRUE); _wb.SaveCopyAs(COleVariant(filePath)); _wb.Close(COleVariant(covFalse),COleVariant(filePa th),COleVariant((long)0)); wb.Close(); xlApp.Quit(); xlApp.ReleaseDispatch(); xlApp = NULL; wb = NULL; ws = NULL; _ws = NULL; _wb = NULL; so am I terminating these in the wrong order? I've tryed different ways... This class is called from button event. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Jul 31, 4:11 pm, "Ronald Dodge" wrote:
Excel doesn't have a "SetSaved" property, but rather a "Saved" property on the workbook. Therefore, the code may be erroring out prior to getting to the lines dealing with closing out the workbooks and app, depending on how you have the app setup to handle run-time errors. Thanks for your responce... Yes the function SetSaved is available... also I changed it as you suggested to Save(); but no luck... process still running... any other sugestion? thanks in advance... -Kevin |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Kevin,
I am far from an expert with C++ but from my experience in using VB6 with Office Apps I would think the problem is in setting the app to null before setting the worksheet and workbook objects to null. Try the follwing arrangement: As a side note, the _ws was not in your original declarations... _wb.SetSaved(TRUE); _wb.SaveCopyAs(COleVariant(filePath)); _wb.Close(COleVariant(covFalse),COleVariant(filePa th),COleVariant((long)0)); wb.Close(); \\ Remove Worksheet references ws = NULL; _ws = NULL; \\ Remove Workbook references wb = NULL; _wb = NULL; \\ Close and remove App references xlApp.Quit(); xlApp.ReleaseDispatch(); xlApp = NULL; "Kevin" wrote in message oups.com... On Jul 31, 4:11 pm, "Ronald Dodge" wrote: Excel doesn't have a "SetSaved" property, but rather a "Saved" property on the workbook. Therefore, the code may be erroring out prior to getting to the lines dealing with closing out the workbooks and app, depending on how you have the app setup to handle run-time errors. Thanks for your responce... Yes the function SetSaved is available... also I changed it as you suggested to Save(); but no luck... process still running... any other sugestion? thanks in advance... -Kevin |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Usually is best to clean up your variables from the smallest (child) objects
to the largest (parent) objects, which Dove indirectly was pointing out. The other thing, make sure any code in the BeforeSave or BeforeClose events of the workbook are performing properly, if there is any code in either of them and if the application's EnableEvent is set to "True" (-1). Maybe for the programming languages outside of VBA, there's a different set of methods, properties, and statements available for Excel. I wouldn't know about that as I haven't programmed with C programming, but yet, I have had to convert some C programming code to VBA code to get various applications to be manipulated by VBA within Excel, such as Acrobat Adobe, Lotus Notes, and IBM Personal Communicator. I am currently in the process of getting my MCSD cert, which is taking me a while to go through the training material, though 90% to 95% of the stuff that I have learned is self taught, so many of the stuff is also review. However, since some of the stuff is geared towards .NET stuff, that aspect of it is relatively new to me, but still uses all the same general programming stuff in terms of how you would create your code even though the syntax is different in many respects and the object interactions in some cases are different too. But yet, the more changes that I see, the more of the same I also see. There's one major thing I don't like about the .NET stuff, though I fully understand their reasoning for getting rid of it, I still think there's rare occassions of when it may still be needed. They got rid of the GoTo statement. The single biggest reason why they got rid of it is simply cause people have used it in improper ways creating bad programming practices. Now you have to use the Try...Catch method in it's place. -- Sincerely, Ronald R. Dodge, Jr. Master MOUS 2000 "Kevin" wrote in message oups.com... On Jul 31, 4:11 pm, "Ronald Dodge" wrote: Excel doesn't have a "SetSaved" property, but rather a "Saved" property on the workbook. Therefore, the code may be erroring out prior to getting to the lines dealing with closing out the workbooks and app, depending on how you have the app setup to handle run-time errors. Thanks for your responce... Yes the function SetSaved is available... also I changed it as you suggested to Save(); but no luck... process still running... any other sugestion? thanks in advance... -Kevin |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Again... I've tryed your sugestions but still nothing is
working the right way... I have debuged it setting: xlApp.SetUserControl(true); xlApp.SetVisible(true); I have seen everything shutdown normally except that the process still is running... I just think its kind of anoying that only when the whole application shuts down only then it terminates the excel process. About the DoEvent() function is there something like this for C++? thanks! -Kevin |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't know if it's available for C++. Works for sure in VBScript,
Outlook and Excel VBA - tested there. Note the "s" its DoEvents() About the DoEvent() function is there something like this for C++? thanks! -Kevin |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Jul 31, 11:13 am, Kevin wrote:
I have a code which automates few things to create an excel file. The problem is that once its done and saves the file and closes it the excel process still is running in the background. It terminates it self after the app completely closes it's self. here is a pice of my code: ================================================== ===== xlApp.SetUserControl(false); xlApp.SetVisible(false); wb = xlApp.GetWorkbooks(); _wb = wb.Add(covOptional); ws = _wb.GetSheets(); //Automate some stuff... _wb.SetSaved(TRUE); _wb.SaveCopyAs(COleVariant(filePath)); _wb.Close(COleVariant(covFalse),COleVariant(filePa th),COleVariant((long)0)) ; wb.Close(); xlApp.Quit(); xlApp.ReleaseDispatch(); xlApp = NULL; wb = NULL; ws = NULL; _ws = NULL; _wb = NULL; so am I terminating these in the wrong order? I've tryed different ways... This class is called from button event. Try closing the active x object u created to open xl. Add DoEvents() calls to give control to the OS. Make XL visible to debug. Confirm process is from current script. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel window closed but process still running | Excel Programming | |||
Excel.Application.Quit leaving Excel process stays active | Excel Programming | |||
How to Kill Excel application process | Excel Programming | |||
Providing Estimate to Complete Info on a Process | Excel Programming | |||
Mail merge issue - ghost Excel process remains after closing application | Excel Programming |