Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Finding and replacing text in word document with fmp data using Applescript

Featured Replies

I am trying to get around merging files.

I have a database of Matters in filemaker pro advanced.

I have created a script in the matters file which uses applescript to open a word template file, rename it according to the name of the record I ran the script from and save it with the new name. This part of the script works fine.

It is implemented by using a global field with the filename in it and setting a variable in applescript by reference to the global field: "get cell"

The new file is a letter - I want to be able to extract the name of the matter from the filemaker database and place it at a specific location in the word document.

My plan is to have a unique word on the document and to search for that word and replace it with a variable in applescript derived from a field in filemaker.

I want to do this, if it can be done, without closing the document I have just created.

after much trial and error i am getting the feeling that I may not be able to do this unless i close the document first and/or that you cant use defined variable in the search replace "command" (if that is what it is - forgive me I am not a programmer or anything)

Thanks in anticipation.

  • Author

solved it

set thename to cell "documentname"

set {day:d, month:m, year:y} to (current date)

set theDate to (d," ", m,", ", y) as string

set thefirm to cell "Firmname"

set theaddress to cell "Address"

set theref to cell "Reference"

set thematter to cell "Mattername"

tell application "Microsoft Word"

activate

open "Macintosh HD:Fees_Program:Documents:Templates:Letter.dot"

save as active document file name "Macintosh HD:Fees_Program:Documents:My Documents:"& thename

end tell

tell application "Microsoft Word"

set findRange to find object of selection

tell findRange

execute find find text "Date" replace with thedate replace replace all

end tell

end tell

tell application "Microsoft Word"

set findRange to find object of selection

tell findRange

execute find find text "Firm" replace with thefirm replace replace all

end tell

end tell

tell application "Microsoft Word"

set findRange to find object of selection

tell findRange

execute find find text "Address" replace with theaddress replace replace all

end tell

end tell

tell application "Microsoft Word"

set findRange to find object of selection

tell findRange

execute find find text "zf" replace with theref replace replace all

end tell

end tell

tell application "Microsoft Word"

set findRange to find object of selection

tell findRange

execute find find text "Matter" replace with thematter replace replace all

end tell

end tell

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.