Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
InDesign COM not supported?
#1
Hmm, I thought I'd try using COM to automate InDesign:

Code:
Copy      Help
function str'group str'style
typelib InDesign {531EBB2B-227C-4732-A979-00052EFF35D5} 1.0

InDesign.Application idApp._create

I immediately got the error, "type library error: type kind not supported. ."

Am I out of luck here? or is there another way?

VBA code looks like this:
Code:
Copy      Help
Dim oidApp As New InDesign.Application
Dim oidDoc As InDesign.Document
Set oidDoc = oidApp.ActiveDocument

Thanks!

Tony
#2
QM does not support some rarely used things in type libraries. But I never saw such error in >10 years.

Try without a type library.

IDispatch oidApp._create("InDesign.Application")
IDispatch oidDoc=oidApp.ActiveDocument

With IDispatch you will not see the method lists in QM. But converting from VBA is easier.
#3
Hmm good idea. I tried that, and after a very long delay (30 seconds) I get Error (RT) in ChangeParagraphStyle: 0x80080005, Server execution failed.

Code:
Copy      Help
function str'group str'style
IDispatch oidApp._create("InDesign.Application")
IDispatch oidDoc=oidApp.ActiveDocument
#4
I'm sorry, must be _getactive, not _create.

Code:
Copy      Help
IDispatch oidApp._getactive("InDesign.Application")
IDispatch oidDoc=oidApp.ActiveDocument

Also, the macro should be running as User, not as admin.
Macro Macro2445
Code:
Copy      Help
;/exe 1
ChangeParagraphStyle ...
#5
Running as user seems to be the trick--partially. (._getactive does not work but ._create does--when running as user).

The following code runs without error--yay, partial success! But, it also does nothing. (It should delete selected text.)

Code:
Copy      Help
IDispatch oidApp._create("InDesign.Application")
IDispatch oidDoc=oidApp.ActiveDocument
out oidApp.Selection.Count
oidApp.Selection[0].Delete

Interestingly it does output the correct count of currently selected items, but does not delete them.

Here's working VB code:
Code:
Copy      Help
Dim oidApp As New InDesign.Application
  
  Dim oidDoc As InDesign.Document
  Set oidDoc = oidApp.ActiveDocument
  
  oidApp.Selection(1).Delete
#6
Try
oidApp.Selection(1).Delete
or
oidApp.Selection.Item(1).Delete

or VBScript
Macro Macro2447
Code:
Copy      Help
;/exe 1
str vbs=
;Set oidApp=CreateObject("InDesign.Application")
;Set oidDoc = oidApp.ActiveDocument
;oidApp.Selection(1).Delete
VbsExec vbs
#7
WOW!! Big Grin

You can run VBS from QM?! I never knew that!

Changing the index to 1-based and using parentheses worked! So did executing vbscript directly.

Very cool. 8)


Forum Jump:


Users browsing this thread: 1 Guest(s)