Microsoft Word和AppleScript(更改页眉)

3

我有两个文档。我希望将第一个文档的页眉复制到第二个文档中(保持完全相同的格式、页面编号等)。以下是我目前的源代码:

tell application "Microsoft Word"
    activate
    open "Macintosh HD:test.docx"
    open "Macintosh HD:newtest.docx"
    set doc to document "Macintosh HD:test.docx"
    set doc2 to document "Macintosh HD:newtest.docx"

    set refHeader to get header of section 1 of doc index header footer primary

end tell

我该如何将refHeader设置为doc2的页眉? 谢谢。
我尝试了这个方法,但它不起作用,给了我一个错误:
set refHeader to page number options of (get header of section 1 of doc index header footer primary)
    set page number options of (get header of section 1 of doc2 index header footer primary) to refHeader
1个回答

2

这看起来相当复杂,但完成了任务。可能有更好的方法,但我不确定。

tell application "Microsoft Word"
    activate
    open "Macintosh HD:test.docx"
    open "Macintosh HD:newtest.docx"
    set doc to document "Macintosh HD:test.docx"
    set doc2 to document "Macintosh HD:newtest.docx"

    set refHeader to content of text object of (get header of section 1 of doc index header footer primary)
    set props to properties of text object of (get header of section 1 of doc index header footer primary)
    set content of text object of (get header of section 1 of doc2 index header footer primary) to refHeader
    set properties of text object of (get header of section 1 of doc2 index header footer primary) to props
end tell

@user635064 这个做你想要的吗? - mcgrailm
所以它正在复制它,但没有保留样式吗? - mcgrailm
我认为您可能需要通过 AppleScript 单独设置样式。 - mcgrailm
再次感谢您的回复。您能给我一些提示,告诉我如何做吗?谢谢。 - user635064
我想通了,这并不难。 - mcgrailm
显示剩余4条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接