S
spaschke
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Power PC I have here a sample script that creates a field in a word document. At the creation of the field, according to the little documentation I could find, you can set the properties of the field, including field code, result range and field text.
1. The field text is not supposed to show. - it does. It shows as part of the field code. I did not include this in my sample. I don't really need it anyway.
2. In the statement creating the field, the field code doesn't get set as you can see by running the script. I have to set it later.
3. The result range also doesn't get set at field creation. Setting the result range later also does NOT put it in the field like Word of Windows does, it puts it as static text in the document.
I really need the result range to work. Am I doing something wrong here? I have tried it many many ways and can't get it to work as documented.
tell application "Microsoft Word"
collapse range text object of selection direction collapse start
set myrange to text object of selection
set insertionPoint to start of content of myrange --save this point
set myField to make new field at character insertionPoint of active document with properties ¬
{text range:myrange, field type:field addin, field code:"ADDIN {{the original field code}}", show codes:true, result range:"{{first setting of the result range}}"}
display dialog "check the field"
set content of (field code of field 1 of active document) ¬
to " ADDIN {{The field code}} "
set content of (result range of field 1 of active document) ¬
to "{{the result range reset}} "
end tell
Thanks for taking a look
Steve
1. The field text is not supposed to show. - it does. It shows as part of the field code. I did not include this in my sample. I don't really need it anyway.
2. In the statement creating the field, the field code doesn't get set as you can see by running the script. I have to set it later.
3. The result range also doesn't get set at field creation. Setting the result range later also does NOT put it in the field like Word of Windows does, it puts it as static text in the document.
I really need the result range to work. Am I doing something wrong here? I have tried it many many ways and can't get it to work as documented.
tell application "Microsoft Word"
collapse range text object of selection direction collapse start
set myrange to text object of selection
set insertionPoint to start of content of myrange --save this point
set myField to make new field at character insertionPoint of active document with properties ¬
{text range:myrange, field type:field addin, field code:"ADDIN {{the original field code}}", show codes:true, result range:"{{first setting of the result range}}"}
display dialog "check the field"
set content of (field code of field 1 of active document) ¬
to " ADDIN {{The field code}} "
set content of (result range of field 1 of active document) ¬
to "{{the result range reset}} "
end tell
Thanks for taking a look
Steve