Hi there, im entering text into microsoft word uisng applescript, however i was wondering if there was a way to change the font size that is being copied in… my script so far goes…
tell application "Microsoft Word"
activate
end tell
tell application "System Events"
keystroke "hello there"
end tell
Perhaps something like this
tell application "Microsoft Word"
--activate
set textToInsert to "Hello there "
set startingAtChr to 3
set newFontSize to 18
if length of (content of text object of active document as text) ≤ startingAtChr then
set startingAtChr to (length of (content of text object of active document as text)) - 1
end if
set myRange to create range active document start startingAtChr end startingAtChr
insert text textToInsert at myRange
set myRange to create range active document start startingAtChr end (startingAtChr + (length of textToInsert))
set (font size of font object of myRange) to newFontSize
end tell
thanks
I need to apply the font size change to the whole document, is there any way that can be done? cause im inporting dynamically from address book so the text is changing length all the time
The previous script set the font size of the inserted text, regardless of length.
This script sizes the font of the whole document.
tell application "Microsoft Word"
--activate
set textToInsert to "Hello there "
set startingAtChr to 3
set newFontSize to 18
set documentTextRange to text object of active document
set textOfDocument to (content of documentTextRange) as text
if length of (textOfDocument) ≤ startingAtChr then
set startingAtChr to (length of textOfDocument) - 1
end if
insert text textToInsert at (create range active document start startingAtChr end startingAtChr)
set (font size of font object of documentTextRange) to newFontSize
end tell
I edited that a tincy bit and it worked perfectly, thank you 