Word 2008 - Add footnote

Good mornng

I have this script:

tell application "Microsoft Word"
	make new footnote at active document
end tell

Which works fine except that the cursor does not jump to the text of the footnote. I am looking to add a hot key to add a footnote. Hence the script. Does anyone know how I make the cursor jump to the footnote text to begin typing there? At the moment, the script creates the footnote with contents “No reference” with the cursor remaining in the main body text, just before the newly created footnote number. So I have to scroll down, double click the “no reference” and type over. So not a good solution at the moment.

Thanks

Does this do what you want?

tell application "Microsoft Word"
	activate
	set myFootnote to make new footnote at active document with properties {text range:text object of selection}
	select note reference of myFootnote
end tell

The new footnote syntax came from
http://www.microsoft.com/mac/developers/default.mspx?CTT=PageView&clr=99-21-0&target=4acff5ca-5863-4bb6-9a3b-09d2bc0d1dc71033&srcid=e1dbbe49-e45b-4606-bc00-dc5d3bd2d4601033&ep=7

Thanks for the reply

Almost worked. Your script selected the footnote number in main text.

One small change required to make it select the text of the footnote:


tell application "Microsoft Word"
	activate
	set myFootnote to make new footnote at active document with properties ¬
		{text range:text object of selection}
	select text object of myFootnote
	delete selection
end tell

One question though. How do I stop it filling the text of the footnote with “No reference”? My solution (not elegant) is to issue a delete selection command.I would like to fill it directly with a blank so that it works like inserting a footnote from the menu, and thereby avoiding need to delete.

Finally, I wonder how to get the script to jump back to the footnote number. I would like to assign a hot key to a script that does this. Is it possible to ask Word to detect which footnote the cursor is in, then jump back to the footnote number in the main text? The jump back seems possible using your command “select note reference of myFootnote” (with some command to move the cursor forward one after this). But how to populate the variable myFootnote with the note reference?

Thanks

I’m not sure how do to that.

In regards to the switch-from-footnote-to-reference, It looks like your script has already defined the myFootnote.

OK

The footnote number is defined but if you invoke a script to make the jump back, the footnote number will need to be determined somehow.

Perhaps someone else will have some suggestions.

Thanks for your input. I at least have a quick insert of footnote now, even if I still have to resort to mousing to get back after typing footnote text.

Slightly upgraded script which avoids the workaround of deleting the text in the footnote:

try
	tell application "Microsoft Word"
		activate
		set myFootnote to make new footnote at active document with properties ¬
			{text range:text object of selection}
		set content of text object of myFootnote to ""
		select text object of myFootnote
	end tell
end try

Still stymied in trying to determine whether the cursor is in a footnote, and if so, determine the footnote number.

Best solution found so far is to use MS built in Macros.

Thus CMD ALT F inserts footnote. And CMD ALT Z sends the cursor back to the last insertion point in the body text (ie just after the footnote number).

Not ideal, as it will not help if you click in to the footnote from elsewhere. But best clunk solution I can drum up. No applescript required:(

Cheers