problems with GetObject 
Author Message
 problems with GetObject

I'm having using wscript.getobject to close previously running Office
applictions.  For example, I can use createobject to launch Excel 97, do
some stuff and close the application.

However, I want to access a previously opened Excel application and close
it.  I can close the workspace but whenever I try to use the
Excel.Application, I get the class doesn't support automation error.

dim obj
set obj = Wscript.GetObject("c:\temp\test.xls",Excel.Application","obj_")
obj.Quit
set obj = nothing

Sub obj_quit
Wscript.echo "Closing Excel"
End sub

From what I can see, this should work.  If I change Excel.Application to
Excel.workspace, the file closes but the application remains open.  Am I
missing something painfully obvious to the rest of you.




Fri, 18 May 2001 03:00:00 GMT  
 problems with GetObject

Quote:

> I'm having using wscript.getobject to close previously running Office
> applictions.  For example, I can use createobject to launch Excel 97, do
> some stuff and close the application.

> However, I want to access a previously opened Excel application and close
> it.  I can close the workspace but whenever I try to use the
> Excel.Application, I get the class doesn't support automation error.

> dim obj
> set obj = Wscript.GetObject("c:\temp\test.xls",Excel.Application","obj_")
> obj.Quit
> set obj = nothing

> Sub obj_quit
> Wscript.echo "Closing Excel"
> End sub

> From what I can see, this should work.  If I change Excel.Application to
> Excel.workspace, the file closes but the application remains open.  Am I
> missing something painfully obvious to the rest of you.



I recently automated a Word application (Should have very similar syntax
to Excel) and used ...

    objWord.Application.Quit

to close it, though I opened the application with

    Set objWord  = WScript.CreateObject("Word.Application")

and opened the desired document with something like ...

    objWord.Documents.Open("c:\temp\test.xls")

Don't know whether that makes a difference or whether this is exactly
right for Excel.

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/



Fri, 18 May 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problems with GetObject function

2. Problem with GetObject

3. Problem With GetObject

4. Problems with GetObject

5. adsi problem with getobject(adspath)

6. Problem with GetObject

7. Problem with GetObject

8. Problem with GetObject after installing NT Security Rollup Package (SRP)

9. Problem with GetObject

10. Problems with GetObject and .cpp files in Visual Studio...

11. GetObject problem

12. GetObject Problem ("Access.Application")

 

 
Powered by phpBB® Forum Software