2013-04-16 120 views
4

我有一個樣品添加爲Excel: 我創建了一個對象InDesign.Application如何使用Adobe InDesign中API在VB.Net

 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中打開,但外接顯示錯誤的:

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

內容錯誤的:

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

爲什麼?你可以幫我嗎?

回答

3

您是否使用vb.net的com界面添加了對InDesign類型庫的引用?

在Visual Studio中打開參考面板,然後選擇「COM」選項卡,然後在列表中查找InDesign。它將默認爲Copy Local = False

現在您可以像使用vbs一樣使用COM函數了。

相關問題