微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Python + Adob​​e Indesign Win32com

如何解决Python + Adob​​e Indesign Win32com

在完成某些工作后,如何自动关闭Adobe InDesing。我尝试app.quit(2036691744)。我如何设置变量SaveOptions = SaveOptions。是(2036691744)。认SaveOptions = SaveOptions.ASK

import win32com.client
import random
import string

def id_generator(size=6,chars=string.ascii_uppercase + string.digits):
    return ''.join(random.choice(chars) for _ in range(size))

voucher=id_generator()
searchText = 'test'

app = win32com.client.dispatch('InDesign.Application')
app.scriptPreferences.userInteractionLevel = 1699640946
myFile = r'D:\alfred\py3\indd\tst.indd'
myDocument = app.Open(myFile,0)
myPage = myDocument.Pages.Item(1)

idnothing = 1851876449  #from enum idnothingEnum,see doc_reference

for it in myDocument.TextFrames:
    #print(it.Contents)
    if searchText in (it.Contents):
        app.FindTextPreferences.FindWhat = searchText
        app.ChangeTextPreferences.Changeto = voucher
        it.ChangeText()
        continue        

    app.FindTextPreferences.FindWhat = idnothing
    app.ChangeTextPreferences.Changeto = idnothing


app.quit(2036691744)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。