Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CreateObject() with ID CS2 broken in Vista (VBA)?

New Here ,
Jun 03, 2008 Jun 03, 2008
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,

jdb
TOPICS
Scripting
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 03, 2008 Jun 03, 2008
Hi Joel,

Several questions:

Have you added a reference to the InDesign object library in your VBA macro? (I forget to do this every time I update Office--sometimes it carries over; sometimes it doesn't.)

Can you run .vbs scripts from the InDesign Scripts panel?

Do you have read/write permissions on all of the folders in the path to the "Resources for Visual Basic.tlb" file (you'll probably have to search for it--lots of places it could be in Vista).

Thanks,

Ole
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 04, 2008 Jun 04, 2008
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.

Thanks,

jdb
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 04, 2008 Jun 04, 2008
UPDATE:

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

Here's the call in Ruby: indesign = WIN32OLE.new("indesign.application")

Not enough storage? Same as out of memory? Maybe this error code will help? Any more ideas?

Thanks for your help!

jdb
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 04, 2008 Jun 04, 2008
Hi Joel,

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!

Thanks,

Ole
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 04, 2008 Jun 04, 2008
If I go in and rewrite everything from an InDesign/JScript perspective, I will need to create an object to automate Excel, still, within the application, so I can get info into InDesign.

I may opt to code in JavaScript/JScript this time. Do you know the equivalent way in JavaScript/JScript to create an Excel application automation object like CreateObject() in VBA/VBScript?

i.e., what in JavaScript is equal to myInDesign = CreateObject("InDesign.Application")?

Thanks,

jdb
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 04, 2008 Jun 04, 2008
Hi Joel,

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.

Here's a VBScript that does something in Excel.

Set myExcel = CreateObject("Excel.Application")
myExcel.Visible = True
myExcel.Workbooks.Add
myExcel.Cells(1, 1).Value = "Hello World"

If you run this from InDesign's Scripts panel, it should create a new workbook in Excel and add text to the first cell. If it doesn't, we might have some other problem.

Thanks,

Ole
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 04, 2008 Jun 04, 2008
Gotcha. I'll try it.

Now, for my next trick:

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...

jdb
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 04, 2008 Jun 04, 2008
Hi Joel,

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.

In any case, I want to figure out what the original problem is.

Thanks,

Ole
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 04, 2008 Jun 04, 2008
I agree. I hope you do find the problem. If I am having trouble with it, then you can be sure others who have moved to Vista are! ;0)

Besides the Ruby script error dump above, check out the following screenshots of my attempts to connect within VB and C# 2005. Maybe they will help guide you in the right direction:

http://www.theretailcoach.net/images/vs_InDesign_error.PNG
http://www.theretailcoach.net/images/vs_InDesign_error2.PNG
http://www.theretailcoach.net/images/vs_InDesign_error3.PNG

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...

Anyway, good luck. Keep me posted...

Thanks,

jdb
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 04, 2008 Jun 04, 2008
Hi Joel,

Does anything happen when you use regtlb.exe to attempt to register the InDesign .tlb file?

Thanks,

Ole
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 04, 2008 Jun 04, 2008
I'll try that. In the meantime, here's something for you. The following script (saved as test.vbs) actually WORKS from the command prompt "cscript test.vbs":

' BEGIN CODE
Dim WSHShell
Dim myInDesign
Dim myDocument
Dim myMessage

Set WSHShell = CreateObject("WScript.Shell")
WSHShell.Run """C:\Program Files\Adobe\Adobe InDesign CS2\InDesign.exe""", 0, False

Set myInDesign = CreateObject("InDesign.Application.CS2")

myInDesign.Activate
Set myDocument = myInDesign.Open("C:\Users\Joel\_Template.indd")

set myMessage = new progMessage
myMessage.setMessage(myInDesign.ActiveDocument.name)
myMessage.Display

myInDesign.Quit
Set myInDesign = Nothing

Class progMessage
Private messageText

public sub setMessage(s)
messageText = s
end sub

public sub Display
msgbox "Message: " & messageText
end sub

end class
' END CODE

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!

Thanks,

jdb
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 04, 2008 Jun 04, 2008
Ole,

Where do I get regtlb.exe? I can't find it on my hard drive. Can you send it to me: [joel DOT berry AT hotmail DOT com]? I'll test it if you can get it to me.

Thanks,

jdb
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 05, 2008 Jun 05, 2008
Hi Joel,

Have you seen this other thread?

http://www.adobeforums.com/webx/.3bbf275d.3c064bf7/12

...might help.

Thanks,

Ole
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 05, 2008 Jun 05, 2008
LATEST
Ole,

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.

Any ideas?

Thanks,

jdb
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines