I posted earlier under a fairly ambiguous subject, so I am re-trying here--forgive the dual post, please...

but I think I have narrowed it down. It appears to be a problem with InDesign CS2 and Vista. I can't get any application to call CreateObject successfully without an "Out of memory" error on the call: even from the command line using .vbs.

Does ANYONE have any idea what's going on? Or any ideas? Ole, you out there?

Thanks, Ole -- yes, I added the reference to the project. I'll check the other two and get back with you. On a side note, I even tried to run it from a C# .net application and got the same out of memory error.

I have modified the permissions on the folders in the path to "Resources for Visual Basic.tlb" (in the C:\ProgramData folder). No joy. Still get an out of memory error.

I did try running a sample script to create an InDesign Object and then open a file, display the filename and then close the file, then quit InDesign. It worked as a .vbs under the Scripts folder from within InDesign.

I don't know why I can't script this from a VBA host, though. If at all possible, I would rather not re-do the script as it is designed to run from within Excel, pulling data from numerous sheets, charts, etc.

UPDATE#2:

I even tried to create an object from Ruby using WIN32OLE. Here is the message I got:

C:\Users\Joel\Documents>ruby test.rb
test.rb:49:in `initialize': failed to create WIN32OLE object from `indesign.application' (WIN32OLERuntimeError)
HRESULT error code:0x8007000e
Not enough storage is available to complete this operation. from test.rb:49:in `new'
from test.rb:49

To start with, I think the out of memory error is bogus. It's most likely that something else is wrong, and that InDesign is just tossing that error out as its best guess.

Next, for a short term solution, you could take the opposite approach: right now, your VBA runs in Excel and contacts InDesign; you could, instead, create a VBScript that you run in InDesign that then creates an Excel object and does its work there.

We're hearing reports of similar problems from other Vista users--you can see some in this forum. I haven't really been able to track it down, because I'm still mostly running XP, and because the only Vista I have is a VMWare virtual machine (where everything seems to work). I don't have the newest Mac OS release, either--there's just too much work to get done to go through a system update!

Why not use a VBScript? You've already got the VBA working in Excel, and converting that to a VBScript should be easy. Even if you write the script in ExtendScript/JavaScript (not JScript), you'll have to use a VBScript to talk to Excel--ExtendScript doesn't know anything about Excel.

Inside my Excel VBA code as it is now, I have created two classes/objects (class modules) that I use to control InDesign (each object stores a bunch of information from various spreadsheets so that I can just create objects as needed and call the methods of the objects to control InDesign. i.e., instead of a top-down script, this is much more modular and keeps the code cleaner).

Is there a way to create inline objects in VBScript? That was one of the reasons I was asking about JavaScript/JScript. I need (ideally) to re-create these objects somehow...

I *think* there's a way to tell Excel to run its own VBA programs--soemthing like InDesign's DoScript method. It might be that everything you need to do can be done without having to rewrite those functions at all--maybe you can make your InDesign VBScript take care of the only the communication between the applications, while your VBA continues to crunch along in Excel as it always has.

Hope these help. For some reason, I can't hit the InDesign scripting engine from ANY language or VBA hosting application outside of InDesign itself...

This is a brand new, fresh install of Vista. Ironically, when I "upgraded" my system from XP to Vista, it worked, but I was having all kinds of other problems (i.e., legacy code messing up operations in Vista, Vista refusing to update itself on occasion, etc.) so I formatted my machine and did a clean install... I installed Office 2007 before I installed Adobe InDesign CS2, but that shouldn't make a difference, as the type library was available in Office 2007 Excel for me to add to my references for that project, so I don't know...

So, you CAN create classes within vbs (at least those run from the command prompt and from within InDesign) AND it seems to create the InDesign object just fine. Weird. This code snippet may help your diagnosis...

UPDATE:

Now, it's not working from the command line. It IS working from the .vbs script in InDesign. Weird. It's always fun trying to find an error when it occurs inconsistently!

I read the posts at the link you provided, and now I am trying to re-register my .tlb file with regtlb.exe, but I keep getting an "Invalid Library name specified". I am running it from the command line with Administrator privileges.