Hi,
Need help on eliminating these 2 problems in the following script:
-
In the variable fileName I also get the \r character. I would like to remove this last character. Or not getting it in the first place.
-
In my newDoc, I would like to remove the last Paragraph and I would like to remove the Section break.
Thanks for the help.
set NbSections to 0
set Compteur to 0
set pathToOutput to (path to desktop as text) & "Output:"
tell application "Microsoft Word"
set NbSections to count sections of active document
repeat with Compteur from 1 to NbSections
set myRange to create range active document start (start of content of text object of section Compteur of active document) end (end of content of text object of section Compteur of active document)
select myRange
copy object selection
set newDoc to make new document
paste object text object of selection
set fileName to get content of text object of paragraph 2 of newDoc
save newDoc in pathToOutput & fileName & ".docx"
close front document
end repeat
end tell