forked from DonovanChan/applescripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLIB_Pages.applescript
More file actions
22 lines (19 loc) · 804 Bytes
/
LIB_Pages.applescript
File metadata and controls
22 lines (19 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
---------------------------------------------
-- SCRIPT LIBRARY: Pages
---------------------------------------------
-- HELPFUL REFERENCES
-- http://iworkautomation.com/pages/index.html
-- HANDLER: Replaces text in body of Pages document
-- Using methods of body text object because coercing it to text and using the typical text manipulation methods will remove the rich text formatting
to substituteInBody(theDocument, searchValue, replaceValue)
tell application "Pages"
tell theDocument
tell body text
set matchStart to offset of searchValue in (every character as text)
set matchEnd to matchStart + (length of searchValue)
delete (characters (matchStart + 1) thru (matchEnd - 1))
set character matchStart to replaceValue
end tell
end tell
end tell
end substituteInBody