views:

430

answers:

1

I'm trying to get details of the graphics in an InDesign file. For technical reasons I'm using COM. Not my favourite, as (discussed elsewhere in StackOverflow) you have to spend half your life casting. In Theory (!), the code snippet belwo should work. Intellisense shows doc.AllGraphics as returning objects.

The CS3 scripting reference at http://www.indesignscriptingreference.com/CS3/JavaScript/Document.htm shows it as Array of Graphic

for (int g = 1; g <= doc.AllGraphics.Count; g++) {
  InDesign.Graphic graphic = (InDesign.Graphic) doc.AllGraphics[ g ];
  ....
}

However, I get this error message:

Unable to cast COM object of type 'System.__ComObject' to interface type 'InDesign.Graphic'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{6AE52037-9E4E-442D-ADFC-2D492B4BCBEF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

I've tried using alternative constructs to return an object and then cast this to an Indesign.Graphic. All fail with the same error. I can't believe that Adobe missed including this interface.

Any suggestions as to a solution so I can get the graphic content?

A: 

I am running Win7 64 and CS4 here and had the E_NOInterface message too. It took me 6 hours to solve it via google, try and error. On my way thru the internet I saw your posting here and came back to write you what helped me.

During install the Com-Objects are not registered correctly. To solve this

go to the folder: for cs3 %ALLUSERSPROFILE%\Adobe\InDesign\Version 5.0\Scripting Support\5.0 in my case: C:\ProgramData\Adobe\InDesignVersion 5.0\Scripting Support\5.0

for cs4: %ALLUSERSPROFILE%\Adobe\InDesign\Version 5.0\Scripting Support\6.0

rename the file "Resources for Visual Basic.tlb" to "Resources for Visual Basic.tlb.old"

open up a command window as administrator

go to the indesign-Folder in my case: C:\Program Files (x86)\Adobe\Adobe InDesign CS4

and launch indesign in the command window by typing: indesign.exe -type

wait for the launch and then you are good to go. with this parameter it registeres the components.

I found that solution here: http://forums.adobe.com/message/1105924#1105924

Hope it helps

cafenervosa
Unfortunately in XP although it recreates the TLB nd adding this as a COM reference to VS2005 turns it into an InterOp DLL it still doesn't work. But thanks for the try.
wilson32