Microsoft Word 和 AppleScript(更改标题)

发布于 2024-11-05 22:42:59 字数 712 浏览 1 评论 0原文

我有 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 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

I have 2 documents. I want the header of first doc to be copied to the second doc (exactly, same formatting, page number options etc..). Here's my source code so far:

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

how can I set refHeader to the header of doc2?
Thanks.

I tried this but it doesn't work, gives me error:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

做个少女永远怀春 2024-11-12 22:42:59

这看起来相当复杂,但这项工作可能是更好的方法,但我不确定

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

this seems pretty elaborate but does the job might be a better way but i"m not sure

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文