AppleScript for copy header from MSoft Word

Discussion in 'Mac Programming' started by Avicenna, May 11, 2011.

  1. macrumors member

    I am trying to copy header of one file to another exactly, including formatting, page number options etc...How can I do it? I tried this so far, but if I have the page number on the right side in test.docx, it doesn't carry over in newtest.docx.

    How can I make it so it copies the formatting too? Here's the code so far:
    tell application "Microsoft Word"
        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 content of text object of (get header of section 1 of doc2 index header footer primary) to refHeader
    end tell
  2. macrumors 65816


    I don't know AppleScript. But have you tried doing this within Word using a VBA macro?

Share This Page