Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python scripts for InDesign on Mac #16

Open
GeirOle opened this issue Jun 21, 2022 · 1 comment
Open

Python scripts for InDesign on Mac #16

GeirOle opened this issue Jun 21, 2022 · 1 comment

Comments

@GeirOle
Copy link

GeirOle commented Jun 21, 2022

Hello,
I would like to make scripts for InDesign in Python3 on Mac. My OS is MacOS 12.4 (Monterey).
I have made a lot of code in the past with Python 2.7, but now the most recent versions of MacOS come with Python3.
That is fine with me. I can switch to Python3.

I did the pip3 install appscript and that went well.
I found some code examples here, but they are all for Windows, and they don't work on Mac.

I have managed to start InDesign and open an InDesign document from Python3 with the following code:

###############################################################
from appscript import *
import os
app = app('/Applications/Adobe InDesign 2022/Adobe InDesign 2022.app')

myFile = '/Users/soc/test-python/test-tables.indd'
myDocument = app.open(myFile)
################################################################

In the examples I have found here the call to open a document is:
myDocument = app.Open(myFile)

That is with capital "O" in open. On Mac, that gives an error message.
So I tried with lower case "o", and then it works.

I have tried to save the document, but then I get an error message.
I have tried with

########################
myDocument.Save(myFile)
########################
and then the error message says:
Unknown property, element or command: 'Save'

If I try with lower case "s":

######################
myDocument.save(myFile)
######################

I get another error:
Command failed: Application could not handle this command. (-1708)

It is a bit strange that code which works on Windows does not work on Mac.

Has anyone managed to write Python scripts for InDesign on Mac?
Is there a reference guide somewhere?

I hope there is some information out there that can help me get going.

With best regards from

Geir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants