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

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Tried out DynamicWrapper object in my vbscript code but could not get it to
work. Was thinking maybe the DynamicWrapper control does not work in Windows
Server 2003 ?? Got this error:

Number:91
Source:Microsoft VBScript runtime error
Description:Object variable not set

when attempting to use the DynamicWrapper object.

I registered it with regsvr32 and got the "success" dialog.

Here is a code snippet:

dim UserWrap
dim hWnd
set UserWrap = CreateObject("DynamicWrapper")
If UserWrap = 0 Then
excelApp.Quit
excelApp = nothing
GenerateResponse = CreateErrMsgFromErr(184, postedXML)
exit function
End If

I have other code after this but it never makes it past this. The UserWrap
object is not getting created, and I'm not sure why. Anyone have any ideas?


"mr_unreliable" wrote:

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: Return after AppActivate
    ... from the TechNet Script library .. ... One such non-standard actX control for calling api's is called ... "DynaWrap", and that can be found on Gunter Born's website. ... It is possible to declare-and-call an api from script, ...
    (microsoft.public.scripting.wsh)
  • Re: Return after AppActivate
    ... There is a way to call api's from script, ... One such non-standard actX control for calling api's is called ... "DynaWrap", and that can be found on Gunter Born's website. ... It is possible to declare-and-call an api from script, ...
    (microsoft.public.scripting.wsh)
  • Re: VBScript causes ActiveX warning
    ... user's PCs to allow just this script. ... <!-- Instruct non-IE browsers to skip over VBScript ... >warning can't be disabled. ... >> that the control may be unsafe to interact with other ...
    (microsoft.public.security)
  • Re: Calling Windows Run
    ... > control (DynaWrap), then this script will get you the ... > It is possible to declare-and-call an api from script, ...
    (microsoft.public.scripting.vbscript)
  • Re: VBScript issue under Windows Server 2000 and 2003
    ... a script error. ... As far as I can tell, the CIntcauses a vbscript ... control, and I am not having any luck with the _controlfp fix. ... the "right" time would be when the offending script is invoked/ ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)