Posts: 16
Threads: 7
Joined: Aug 2005
Hmm, I thought I'd try using COM to automate InDesign:
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:
Dim oidApp As New InDesign.Application
Dim oidDoc As InDesign.Document
Set oidDoc = oidApp.ActiveDocument
Thanks!
Tony
Posts: 12,065
Threads: 140
Joined: Dec 2002
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.
Posts: 16
Threads: 7
Joined: Aug 2005
Hmm good idea. I tried that, and after a very long delay (30 seconds) I get
Error (RT) in ChangeParagraphStyle: 0x80080005, Server execution failed.
function str'group str'style
IDispatch oidApp._create("InDesign.Application")
IDispatch oidDoc=oidApp.ActiveDocument
Posts: 12,065
Threads: 140
Joined: Dec 2002
I'm sorry, must be _getactive, not _create.
IDispatch oidApp._getactive("InDesign.Application")
IDispatch oidDoc=oidApp.ActiveDocument
Also, the macro should be running as User, not as admin.
Macro
Macro2445
;/exe 1
ChangeParagraphStyle ...
Posts: 16
Threads: 7
Joined: Aug 2005
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.)
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:
Dim oidApp As New InDesign.Application
Dim oidDoc As InDesign.Document
Set oidDoc = oidApp.ActiveDocument
oidApp.Selection(1).Delete
Posts: 12,065
Threads: 140
Joined: Dec 2002
Try
oidApp.Selection(1).Delete
or
oidApp.Selection.Item(1).Delete
or VBScript
Macro
Macro2447
;/exe 1
str vbs=
;Set oidApp=CreateObject("InDesign.Application")
;Set oidDoc = oidApp.ActiveDocument
;oidApp.Selection(1).Delete
VbsExec vbs
Posts: 16
Threads: 7
Joined: Aug 2005
WOW!!
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)