Removing Paragraph Breaks in Word

Discussion in 'Mac Programming' started by pcLoadLetter, Mar 23, 2017.

  1. pcLoadLetter, Mar 23, 2017
    Last edited by a moderator: Mar 23, 2017

    pcLoadLetter macrumors newbie

    Mar 23, 2017
    I have this script that combines word files into one file. I then drop that Word file onto Quark and drag it off to the side. The problem I'm having is that the imported text cuts off after the first paragraph and the rest of the text is overflowing. I'm trying to figure out how to replace the paragraph break in the code with something that won't cut off in Quark.

    on open of droppedfiles
       with timeout of 1500 seconds
           tell application "Microsoft Word"
               set new_document to make new document
               repeat with afile in droppedfiles
                   set file_path to afile as string
                   set filename to name of afile
                   set paste_range to text object of new_document
                   set collapsed_range to collapse range paste_range direction collapse end
                   insert file file name file_path at collapsed_range
               end repeat
           end tell
       end timeout
    end open
  2. Mitchboo macrumors newbie


    Mar 29, 2017
    FWIW in Word search and replace, ^t means tab.

    I have no idea about how to apply that in AppleScript. Maybe by plugging keys.

    Calling replace is obtained with shift-Cmd-H, but then the caret is in the replace by field. And tab does not go from one field to the other, or even to the replace all button.

    Word for Mac does support Visual Basic for Applications (VBA) which should automate that, but I have not touched that in ages.
  3. kohlson macrumors 68000

    Apr 23, 2010
    I used to do something similar, but using "find and replace" in word. For example, sometimes documents have 2 "returns" between paragraph, and one at the end of each line. I wanted only one at the end of each para. First search for paragraph "marks"represented by control-p "^p" then replace with a unique string, such as "***". Then, search for ****** (2 instances of paragraph returns) and replace with a single ^p. The result strips away all paragraph marks, then adds one back between each paragraph.

Share This Page