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.

Featured Replies

I have written the following calculated AppleScript:

"tell application " &  Quote ( "Microsoft Word" ) & ¶ &
"activate" & ¶ &
"open" & Quote ( "Macintosh HD:Users:Shared:Guild_Word_Template.dotx") & ¶ &
"set theDate to current date" & ¶ &
"set text of active document to theDate as text" & ¶ &
"save as active document file name " & Quote ( UIN_FOCUS::GT_WORD_FILE_NAME ) & ¶ &
"end tell" & ¶ &
"tell application " & Quote ( "System Events" ) & ¶ &
	"tell process " &  Quote ( "Microsoft Word" ) & ¶ &
		"keystroke " & Quote ( "v" ) & " using {command down}" & ¶ &
                "set theRange to (create range active document start 0 end 23)" & ¶ &
"end tell"  & ¶ &
"end tell"

I have a problem with the line that starts "set theRange". I actually have two more lines after this that I've tested in Script Editor irreverent from FM and they work as expected. If I remove this line in FM my script works well. Any idea what's wrong with this line?

 

Thanks,
Agi

Couple of things.

There is no space after Open.

I much prefer setting a variable to the script contents; then just perform applescript, calculated, $script

I like to do substitutions into the script text.

This way you can view and manipulate the contents of $script while testing.

 

 

Set Variable [ $sourcedoc; Value:"Macintosh HD:Users:Shared:Guild_Word_Template.dotx" ]

Set Variable [ $targetdoc; Value: UIN_FOCUS::GT_WORD_FILE_NAME ]

Set Variable [ $script; Value:

List(
"tell application " & Quote ( "Microsoft Word" ) ;
"activate" ;
"open " & Quote ( $sourcedoc ) ;
"set theDate to current date" ;
"set text of active document to theDate as text" ;
"save as active document file name " & Quote ( $targetdoc ) ;

"end tell" ;
"tell application " & Quote ( "System Events" ) ;
"tell process " & Quote ( "Microsoft Word" ) ;
"keystroke " & Quote ( "v" ) & " using {command down}" ;

"create range active document start 0 end 23";
"set theRange to result";
"end tell" ;
"end tell"
)

 

Perform AppleScript [ Calculated AppleScript: $script ]

The script might need to be more like this:

 

 

List(
"tell application " &  Quote ( "Microsoft Word" ) ;
"activate" ;
"open " & Quote ( $sourcedoc ) ;
"set theDate to current date" ;
"set text of active document to theDate as text" ;
"save as active document file name " & Quote ( $targetdoc ) ;
"end tell" ;
 
"tell application " & Quote ( "System Events" ) ;
"tell process " &  Quote ( "Microsoft Word" ) ;
"keystroke " & Quote ( "v" ) & " using {command down}" ;
"end tell";
"end tell"  ;
 
"tell application " &  Quote ( "Microsoft Word" ) ;
"create range active document start 0 end 23";
"set theRange to result";
"end tell"
)
  • Author

Bruce, thanks for your replies. I do use a variable and have no problem opening Word. As I said the ONLY problem I have is with this line: "set theRange to (create range active document start 0 end 23)"

 

The rest is working, thank you. Do you have an idea for that particular line?

 

Thanks,

Agi

I'm not sure if you revised your script along the lines I suggested.

 

But I note that you're trying to do two things inside a system events - tell app process statement.

 

The keystroke command will work.

 

But the PROCESS does not understand the range command.

 

The APPLICATION understands the range command.

 

As written in my second example.

"The rest is working, thank you. Do you have an idea for that particular line?"

 

( the set range line)

 

Yes. It is inside the wrong TELL statement. It only works when inside a tell application statement.

  • Author

Thanks, but I got it working.

 

The problem was that the AppleScript couldn't be run from a variable, only from a field. I heard other people had this problem, as well.

 

This is the working script calc in FM:

"tell application " &  Quote ( "Microsoft Word" ) & ¶ &
"activate" & ¶ &
"open" & Quote ( "Macintosh HD:Users:Shared:Guild_Word_Template.dotx") & ¶ &
"set theDate to current date" & ¶ &
"set text of active document to theDate as text" & ¶ &
"save as active document file name " & Quote ( UIN_FOCUS::GT_WORD_FILE_NAME ) & ¶ &
"end tell" & ¶ &
"tell application " & Quote ( "System Events" ) & ¶ &
	"tell process " &  Quote ( "Microsoft Word" ) & ¶ &
		"keystroke " & Quote ( "v" ) & " using {command down}" & ¶ &
        "end tell" & ¶ &
"end tell" & ¶ & 
"tell application " & Quote("Microsoft Word") & ¶ &
                "set theRange to  (create range active document start 0 end 23)" & ¶ &
                "select theRange" & ¶ &
                "tell paragraph format of theRange to set alignment to align paragraph center" & ¶ &
"end tell"

Of course, now I'm making my life more complicated by adding page breaks. But I'm getting there. :-)


Now, my question is why I am not getting a notification from this forum, even though I'm following the toping with instant notification...

No that is not the prob. It DOES run from a variable.

  • Author

No, it does not from the variable. Others confirmed it, too.

Yes a perform AppleScript step does work from a variable. I use the method regularly and that was what i tested when diagnosing your missing tell application statement.

I would have to see an example file showing how the attempts differ.

This seems to work for me.

ASW.fp7.zip

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.