|
-
Jun 18th, 2000, 05:50 PM
#1
Thread Starter
Addicted Member
I have written an app that uses excell to produce reports, but there is an error when closing it down, it stays in memory which is shown in the task bar.
Is there any way in which i can remove it, or better still totally destroy it.
here is the last few lines on my code....
objexcel.ActiveWorkbook.[Close] False
objexcel.Application.Quit
Set objexcel = Nothing
Thanks from Rohan
-
Jun 18th, 2000, 06:31 PM
#2
Junior Member
Closing Excel
If you don't need excel open at all (and you don't mind closing any sessions of Excel the user is running!) you could try calling the GetObject() function as in:
set objExcel = GetObject("Excel.Application")
If you omit the "path" argument from the call, GetObject returns an existing instance of the requested object. If there is an error, there are no instances running (visible or not) so you can be sure that your object has been destroyed successfully. If no error occurs, you can then call the Quit method on the object to close it and then set the object to nothing. Keep repeating this until an error occurs, clear the error and continue.
Hope this helps.
We watch in reverence as Narcissus is turned to a flower.
-
Jun 18th, 2000, 06:33 PM
#3
_______
Public objExcel as .... and then put your close and nothings in the exit part of your code ..works for me.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 18th, 2000, 07:04 PM
#4
Thread Starter
Addicted Member
Hi there thank you ,
I know that this may be a bit stupid but do you have any codeed examples that you could show me
Rohan
-
Jun 18th, 2000, 07:44 PM
#5
Junior Member
Here goes...
On Error Resume Next
Dim objExcel as Object
Do Until Err.Number <> 0
Set objExcel = GetObject(, "Excel.Application")
If Err.Number = 0 Then
objExcel.Application.Quit
Set objExcel = Nothing
End If
Loop
We watch in reverence as Narcissus is turned to a flower.
-
Jun 18th, 2000, 08:38 PM
#6
_______
run a macro inside an exel object example
Private Sub Form_Load()
'put this code inside the form load event of the Application
'change the file name and macro name to reflect your file and macro
'this will open Excel and run the macro
'
'create and object (Excel SpreadSheet)
Dim oXL As Object
Set oXL = CreateObject("Excel.Application")
' Open the workbook that contains the macro to run.
oXL.Workbooks.open "C:\My Documents\try.xls"
'
'as object opens invisible, make visible if needed, if not omit
'the line oXL.visible=true
'
oXL.Visible = True
'
' Run the macro.
oXL.Application.Run "try.xls!myMacro"
'
' Quit Microsoft Excel.
oXL.Quit
'
' Free the object from memory.
Set oXL = Nothing
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 28th, 2000, 01:54 PM
#7
Frenzied Member
HeSaidJoe,
please tell me you have a code for me too.
I just want one simple thing. If there is data in cell (A1) on sheet ( sheet1) then the workbook cannot be closed. And if that's too easy for you, then also the workbook cannot be saved (in the same case).
SO, what do you say?
Thanks.
Wen Gang, Programmer
VB6, QB, HTML, ASP, VBScript, Visual C++, Java
-
Sep 28th, 2000, 01:58 PM
#8
Frenzied Member
oh yeah, I mean in an Excel macro, not VB.
THANKS
Wengang
Wen Gang, Programmer
VB6, QB, HTML, ASP, VBScript, Visual C++, Java
-
Sep 28th, 2000, 03:45 PM
#9
Addicted Member
And if all of that stuff doesn't work, try changing this line:
objexcel.ActiveWorkbook.[Close] False
to:
objexcel.Workbooks.Close
Sometimes (always) the default blank workbook loads up and doesn't have anywhere else to go when you close the active workbook.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|