Re: "pool" a tightly controlled set of Excel instances



Brian, microsoft has acknowledged the problem, and provided
a solution, but you are not going to like it.

http://support.microsoft.com/kb/147573

The solution is to send-a-message (WM_USER + 18) to the XL
window, to get it to register itself in the ROT (running
object table).

The problem is that scripting ain't got no capability to
"send messages", i.e., to call the "SendMessage" api. If
microsoft wanted you to be able to call api's from script,
then they would have provided that capability.

So, if you really want the solution, you are going to have
to resort to something that is ugly. Either write yourself
an actX object to call the api, or use somebody else's actX
object to do the job. If you are amenable to the second
possibility, I suggest using DynaWrap, which will allow
you to call api's from script.

Otherwise, switch to some other scripting language (for
example AutoIt3 or FBSL) which have api capabilities built
into the language.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)

--- <DynaWrap Boilerplate> ---
It is possible to declare-and-call an api from script,
but you must use a third-party control to do so,
or else write one yourself.

It has already been correctly pointed out that there
is no api-capability in "pure" script.

If you are willing to use a third-party control, then
one such control, called "DynaWrap", can be found on
Guenter Born's website (note: Guenter refers to it as
"DynaCall"). Here is the link to it:

http://people.freenet.de/gborn/WSHBazaar/WSHDynaCall.htm

On that page you will find a download for the control,
plus some code samples.

Note: you may find additional sample code by searching
the archives of the wsh and vbscript ng's.

Note also: DynaWrap does have its limitations. There are
certain things it can't do. For example, you can't call
api's which take typedefs as parameters, and you can't call
api's "by ordinal". But it will work for most of the
"usual suspects".

And finally, DynaWrap doesn't work entirely as advertised.
For example, it is supposed to allow for the declaration of
several api definitions in one instance of itself. I could
never get that to work (in win9x). You will need a new
instance of DynaWrap for every api, or else re-instantiate
the object for every api. Someday I'm going to learn enough
c++ to fix that...
--- </DynaWrap Boilerplate> ---


Brian Barnett wrote:
Automating Excel 2003 on IIS 6, Windows Server 2003, and VBScript in ASP page. This article (http://support.microsoft.com/kb/257757/en-us) suggests pooling a set of instances, but I don't know how to do that. Can someone provide some sample vbscript code and/or configuration that will allow this?

I have tried simply using GetObject(,"Excel.Application") to attach to a running instance, but it never attaches any of the running instances that are available. I get this error:

Error - Number:429 Source:Microsoft VBScript runtime error Description:ActiveX component can't create object

Even with only this simple code, I still get the error every time the ASP page is requested:

Dim excelApp Set excelApp = GetObject(,"Excel.Application") If (err <> 0) Then Set excelApp = CreateObject("Excel.Application") End If excelApp.UserControl = True excelApp.Visible = True excelApp = Nothing

CreateObject just keeps creating new instances every time through the code.

Thanks,
Brian Barnett
.



Relevant Pages

  • Re: How can I change the Windows Short Date Time format setting?
    ... I don't know how to do this from "pure" script. ... In the SetLocaleInfo api, ... If you are interested in using dynawrap, ... Dim oDW ' as object ...
    (microsoft.public.scripting.vbscript)
  • Re: Vbs Active Window
    ... api's from script, ... One such control is called Dynawrap. ... ' DynaWrap can only accomodate ONE api declaration at a time. ... Set oDW = nothing ' clear any previous instance ...
    (microsoft.public.scripting.vbscript)
  • Re: "pool" a tightly controlled set of Excel instances
    ... an actX object to call the api, ... possibility, I suggest using DynaWrap, which will allow ... you to call api's from script. ... Set excelApp = CreateObject ...
    (microsoft.public.scripting.vbscript)
  • Re: Using User32.dll function from VBScript(WSH)!?
    ... use a third-party control (such as DynaWrap), ... It is possible to declare-and-call an api from script, ... but you must use a third-party control to do so, ...
    (microsoft.public.scripting.vbscript)
  • A Christmas Present (that you didnt ask for)...
    ... it is written in vbs using api's called by DynaWrap to create the graphical interface. ... It has been mentioned in the scripting ng's for years and is frequently suggested for use when somebody wishes to do something outside the realm of "pure" script. ... It is possible to declare-and-call an api from script, but you must use a third-party control to do so, or else write one yourself. ... Private Function RepaintProgBar ...
    (microsoft.public.scripting.vbscript)