Microsoft Word and AppleScript (change title)

I have 2 documents. I want the title of the first document to be copied to the second document (just like formatting, page number options, etc.). Here is my source code:

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 to set refHeader in doc2 header? Thank.

I tried this, but it does not work, gives me an 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
+3
source share
1 answer

it seems rather complicated, but this work might be better, 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
+2
source

All Articles