Thread View: adobe.scripting.indesign
6 messages
6 total messages
Started by Thomas_B._Nielsen
Wed, 14 Jan 2009 10:56
Insert Text Variable
Author: Thomas_B._Nielsen
Date: Wed, 14 Jan 2009 10:56
Date: Wed, 14 Jan 2009 10:56
7 lines
852 bytes
852 bytes
Hello, Need to set the content of a textFrame on a master page to "Current Page Number" a slash and then the missing item "Last Page Number" as found under Type -> Text Variables -> Insert Variable -> "Last Page Number"; How do i add a text variable with scripting? ....parentTextFrames[0].contents = "^N/" + ?????;
Re: Insert Text Variable
Author: Thomas_B._Nielsen
Date: Wed, 14 Jan 2009 10:56
Date: Wed, 14 Jan 2009 10:56
1 lines
612 bytes
612 bytes
Indesign CS4 and JS
Re: Insert Text Variable
Author: Thomas_B._Nielsen
Date: Wed, 14 Jan 2009 14:21
Date: Wed, 14 Jan 2009 14:21
16 lines
1269 bytes
1269 bytes
Found a solution:
try {
myVar = myDocument.textVariables.item("Last Page");
myVar.name;
} catch (e) {
//alert(e);
myVar = myDocument.textVariables.add({name:'Last Page', variableType:VariableTypes.LAST_PAGE_NUMBER_TYPE});
myVar.variableOptions.scope = VariableScopes.DOCUMENT_SCOPE;
}
myFoundItems[i].parentTextFrames[0].contents = SpecialCharacters.autoPageNumber;
myFoundItems[i].parentTextFrames[0].contents += "/";
myFoundItems[i].insertionPoints.lastItem().textVariableInstances.add( {associatedTextVariable : myVar} );
If anyone can tell me how i can use the application text variable "Last Page Number" without having to make a document variable, please post.
Re: Insert Text Variable
Author: Peter Kahrel
Date: Wed, 14 Jan 2009 14:58
Date: Wed, 14 Jan 2009 14:58
10 lines
958 bytes
958 bytes
Thomas,
Since the application text variable you're after is called "Last Page Number", all you need to do is this:
myVar = myDocument.textVariables.item ("Last Page Number");
...
...
myFoundItems[i].insertionPoints.lastItem().textVariableInstances.add( {associatedTextVariable : myVar} );
Peter
Re: Insert Text Variable
Author: Thomas_B._Nielsen
Date: Wed, 14 Jan 2009 15:28
Date: Wed, 14 Jan 2009 15:28
3 lines
771 bytes
771 bytes
Well i tried that (and now once more) but it gives me a Invalid parameter in the line:
myFoundItems[i].insertionPoints.lastItem().textVariableInstances.add( {associatedTextVariable : myVar} );
Re: Insert Text Variable
Author: Peter Kahrel
Date: Wed, 14 Jan 2009 20:01
Date: Wed, 14 Jan 2009 20:01
5 lines
1211 bytes
1211 bytes
Strange -- it should work. Does your document have a variable called "Last Page Number"? (You call it an 'application variable', but these don't exist in that sense. The variables you see in the "Text Variables" dialog are examples created there by Adobe. I deleted them because I have no use for all those variables in every new document that I create. Which is also the reason why I can't really check your problem.) What exactly does the error message say: invalid parameter or invalid value? If you specify a text variable that doesn't exist, you'd expect "invalid value", not "invalid parameter". Peter
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads