D T
D T

Reputation: 3746

How to use Adobe Indesign API in VB.Net

I have got a sample add in for excel: I create a object InDesign.Application

        Dim myInDesign As InDesign.Application
        Dim myDoc As InDesign.Document
        Dim myPage As InDesign.Page

        myInDesign = CType(Activator.CreateInstance(Type.GetTypeFromProgID("InDesign.Application"), True), InDesign.Application)
        myDoc = myInDesign.Documents.Add    
        myDoc = myInDesign.ActiveDocument

InDesign opens, But the add-in shows error at:

`myInDesign = CType(Activator.CreateInstance(Type.GetTypeFromProgID("InDesign.Application"), True), InDesign.Application)`

Content of Error:

Unable to cast COM object of type 'System.__ComObject' to interface type 'InDesign.Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{ABD4CBB2-0CFE-11D1-801D-0060B03C02E4}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

Why? Can you help me?

Upvotes: 4

Views: 3292

Answers (1)

bgmCoder
bgmCoder

Reputation: 6370

Have you added the reference to the InDesign Type Library using vb.net's com interface?

Open the references panel in Visual Studio and choose the "COM" tab, and look for InDesign in your list. It will default to Copy Local = False.

Now you can use the COM functions just like you were writing vbs.

Upvotes: 3

Related Questions