Skip to main content
New Participant
October 18, 2019
Question

InDesign CC and Excel Scripting, Type definition in VBA

  • October 18, 2019
  • 3 replies
  • 3720 views

for years now I am using VBA scripts in Microsoft Excel to control InDesign. I used the code:

Dim InApp as InDesign.Application

Set InApp = CreateObject("InDesign.Application")

 

but now in InDesign CC 2019 this is a 'type mismatch' error. It works if I do:

Dim InApp as Object

Set InApp = CreateObject("InDesign.Application")

 

But then of course I do not have any type information in the debugging view and so on. This is extremely annoying, as I have a lot of objects like InDesign.Font, InDesign.Table, InDesign.Swatches etc.

In Excel I think I have the correct reference to the type library "Adobe InDesign CC 2019 Type Library" located at c:\ProgramData\Adobe\InDesign\Version 14\...

How to get this set up properly?

This topic has been closed for replies.

3 replies

New Participant
March 10, 2020

Hey guys

How are you ?
I need some help to use Indesign with VisualBasic code
I an using MAC, so ... i don't know if it's possible
The library  do not exist in VBA reference

I really need some helps
I want to use VBA to open an Indesign files, and import some text and image in a template

Thanks for your help guy

Erwan

Kasyan Servetsky
Brainiac
March 10, 2020

It's impossible to use VBA on MAC — it's for Windows only. You need Apple Script for this.

Alternatively, you can use a 'JavaScript + Apple Script' approach (my favorite): execute AS from InDesign's JS via doScript() method, sending parameters (arguments) and getting back results if necessary.

New Participant
March 11, 2020

I am on early 2009 Mac Pro — hacked to install Mojave 10.14.4 to support the latest InDesign.

I have MS Office 2016 (version 16.16.7) and have no idea about VBA on Mac.

Maybe you are on MS Office 2019 and things are different there.

As to me, I am more familiar with VB than AS — this is the first programming language I learned.
Anyway, that's the end of the road for me: my company is not going to buy a new Mac so I can't update it.

Here I posted a function to get data from Excel (both VBA and AS versions) which worked for me very well in a few projects. Hope this may get you started.

— Kas


Hey 

Thanks for your answer 
I use VBA in excel visual basic editor
To open it, i had to add the Feature on the top bar of my excel

Thanks for your solution, but i want to drive Indesign with excel, and not drive Excel with indesign
Is that you suggest no ? 
(sorry i am french)

New Participant
October 18, 2019

seems I found it after hours.

I deleted the .tlb type file, started InDesign as administrator, closed it, started InDesign normally again. This recreates the .tlb file yet again, but something else does happen such that it works now. Very dumb indeed, I remember to have read about this somewhere a long time ago for an older version of InDesign, seems not to be fixed yet.

Kasyan Servetsky
Brainiac
October 18, 2019

I wrote about the problem a while ago.