Add Hard Return around Paragraph spacing Before/After in Microsoft Word

OK, this should work now:

tell application "Microsoft Word"
  tell active document
    set spacedBeforePars to paragraph_id of every paragraph where space before is greater than 0
    set spacedAfterPars to paragraph_id of every paragraph where space after is greater than 0
    repeat with theID in spacedBeforePars
      set thePar to (every paragraph whose paragraph_id is theID)
      set thePar to item 1 of the thePar
      insert paragraph at before text object of thePar
    end repeat
    repeat with theID in spacedAfterPars
      set thePar to (every paragraph whose paragraph_id is theID)
      set thePar to item 1 of the thePar
      insert paragraph at after text object of thePar
    end repeat
    set space before of every paragraph to 0
    set space after of every paragraph to 0
    execute find find object of text object find text "^13{3,}" replace with "^p^p" replace replace all match wildcards yes
  end tell
end tell

Sorry for the crap script in my first answer :wink:

2 Likes