Copy link to clipboard
Copied
I'm looking for a way to remove a single change bar from the document using a script.
I can do this manually, using Esc c h - Format>Style>Change Bar.
Usually, I have to do this twice - partly b/c I'm not sure what text set the change bar initially, so I select beyond the text with the change bar, run the command (which sets the text as change bar text), and then run the command again (which removes the new and the original change bars.)
Per the documentation:
Fcodes ([FCodes.TXT_CHANGEBAR]);
should work, but it doesn't seem to. I thought I would have to run it twice, but it doesn't even create the change bar if I run it once.
Fcodes ([FCodes.TXT_BOLD]); does work so the syntax is correct.
Am I doing something wrong, or is there a better way to do this?
I haven't tried yet, but I might be able to ADD a change bar via script by turning on automatic change bars, adding a space, removing the added space, and turning automatic change bars back off.
The bigger issue is removing the change bars. If it can't be done, is there a way to script the Format>Style Drop-down being selected?
In case anyone needs it, I found out I can turn on and off automatic change bars with:
doc.AutoChangeBars=1 or doc.AutoChangeBars=0
and I can remove ALL change bars with:
doc.ClearAllChangebars();
@frameexpert It works!!! - I figured it out!!!
var doc, textRange;
doc = app.ActiveDoc;
textRange = doc.TextSelection;
RemoveChangeBar (textRange, doc);
function RemoveChangeBar (textRange, doc) {
var prop;
// Make a property list containing the change bar.
prop = new PropVal ();
prop.propIdent.num = Constants.FP_ChangeBar;
prop.propVal.valType = Constants.FT_Integer;
prop.propVal.ival = false;
// Apply the property to the text
...
@frameexpert - Is there any chance that value is a reserved word in Extendscript? I tried your code above and it works for removing a change bar (my main concern), but does NOT work for adding one.
This works though:
var doc, textRange;
doc = app.ActiveDoc;
textRange = doc.TextSelection;
applyOrRemoveChangeBar (textRange, 1, doc); // 0 remove; 1 apply
function applyOrRemoveChangeBar (textRange, AppRem, doc) {
var prop;
// Make a property list containing the change bar.
p
...
Copy link to clipboard
Copied
@frameexpert - From your font color post, I tried this, but it gave me a bad argument value:
function applyChangeBar (textRange, doc) {
var prop;
// Make a property list containing the property.
prop = new PropVal ();
prop.propIdent.num = Constants.FP_Changebar;
prop.propVal.valType = Constants.FT_Integer;
prop.propVal.obj = 1;
// Apply the property to the text.
doc.SetTextPropVal (textRange, prop);
} // End applyChangeBar
Copy link to clipboard
Copied
Instead of prop.propVal.obj, try prop.propVal.ival.
Copy link to clipboard
Copied
Change Bar is a character property so it can be applied to one or more text characters. So first you have to find the character(s) that have the Change Bar property applied and then remove it. It's similar to what you did with the color property in one of your other posts.
Copy link to clipboard
Copied
@frameexpert - Thank you.
Color property: https://community.adobe.com/t5/framemaker-discussions/script-to-change-red-text-to-black/td-p/152932...
Based on the above, I would think this would work:
var doc, textRange;
doc = app.ActiveDoc;
textRange = doc.TextSelection;
function applyChangeBar (textRange, doc) {
var prop;
// Make a property list containing the change bar.
prop = new PropVal ();
prop.propIdent.num = Constants.FP_Changebar;
prop.propVal.valType = Constants.FT_Integer;
prop.propVal.ival = 1;
// Apply the property to the text.
doc.SetTextPropVal (textRange, prop);
} // End applyChangeBar
It doesn't give me an error, but it doesn't show or remove the change bar either.
I'm assuming like the color property, I don't have to actually find the affected text. For example if "This text" in "This text has a change bar." had the change bar property applied, I assume I could highlight the entire row and de-apply the change bar. That's basically how we do it manually.
Follow-up: How would I know when to use .ival, or .sval, or .obj, and what to put for the values. I'm guessing it's somewhere in the FDK and I wasn't able to download that.
Copy link to clipboard
Copied
@frameexpert It works!!! - I figured it out!!!
var doc, textRange;
doc = app.ActiveDoc;
textRange = doc.TextSelection;
RemoveChangeBar (textRange, doc);
function RemoveChangeBar (textRange, doc) {
var prop;
// Make a property list containing the change bar.
prop = new PropVal ();
prop.propIdent.num = Constants.FP_ChangeBar;
prop.propVal.valType = Constants.FT_Integer;
prop.propVal.ival = false;
// Apply the property to the text.
doc.SetTextPropVal (textRange, prop);
} // End RemoveChangeBar
I'll make a new post on how I got here soon, but it wasn't that easy ...
Copy link to clipboard
Copied
Figured it out through a combination of things:
First off, the code I posted earlier, never called the function, so it didn't generate an error, but it didn't actually work either.
I went back to my earlier post on the FDK: https://community.adobe.com/t5/framemaker-discussions/need-a-script-to-display-print-dialog/m-p/1524...
Downloaded the file again and it failed again. There is a setup.exe file. It won't work. Find the FDK15.zip file from the extacted file. Copy it to a new directory and extract it. Look in the \1\Application\Doc\ folder and open the fdkreference.pdf file and search for "changebar". Page 476 says "The following code turns off changebars for the selected text:
/* Set up the property. */
prop.propIdent.num = FP_ChangeBar;
prop.propVal.valType = FT_Integer;
prop.propVal.u.ival = False;"
but not of that works. You have to change FP_ChangeBar to Constants.FP_Changebar. You have to change FT_Integer to Constants.FP_Integer. You'll get an error that False is undefined, so you have to change that to false. You get an errror that prop.propVal.u.ival is not a valid id, so you have to change that to prop.propVal.ival.
THEN it works!!!
Copy link to clipboard
Copied
First of all, I don't see a call to the function in your code. Second, Constants and property names are case-sensitive. You want FP_ChangeBar (capital B).
var doc, textRange;
doc = app.ActiveDoc;
textRange = doc.TextSelection;
applyChangeBar (textRange, doc);
function applyChangeBar (textRange, doc) {
var prop;
// Make a property list containing the change bar.
prop = new PropVal ();
prop.propIdent.num = Constants.FP_ChangeBar;
prop.propVal.valType = Constants.FT_Integer;
prop.propVal.ival = 1;
// Apply the property to the text.
doc.SetTextPropVal (textRange, prop);
} // End applyChangeBar
Copy link to clipboard
Copied
It looks like you figured it out. You could generalize the function to either add or remove change bars.
var doc, textRange;
doc = app.ActiveDoc;
textRange = doc.TextSelection;
applyOrRemoveChangeBar (textRange, 0, doc); // 0 remove; 1 apply
function applyOrRemoveChangeBar (textRange, value, doc) {
var prop;
// Make a property list containing the change bar.
prop = new PropVal ();
prop.propIdent.num = Constants.FP_ChangeBar;
prop.propVal.valType = Constants.FT_Integer;
prop.propVal.ival = value;
// Apply the property to the text.
doc.SetTextPropVal (textRange, prop);
} // End applyOrRemoveChangeBar
Copy link to clipboard
Copied
@frameexpert - Is there any chance that value is a reserved word in Extendscript? I tried your code above and it works for removing a change bar (my main concern), but does NOT work for adding one.
This works though:
var doc, textRange;
doc = app.ActiveDoc;
textRange = doc.TextSelection;
applyOrRemoveChangeBar (textRange, 1, doc); // 0 remove; 1 apply
function applyOrRemoveChangeBar (textRange, AppRem, doc) {
var prop;
// Make a property list containing the change bar.
prop = new PropVal ();
prop.propIdent.num = Constants.FP_ChangeBar;
prop.propVal.valType = Constants.FT_Integer;
prop.propVal.ival = AppRem;
// Apply the property to the text.
doc.SetTextPropVal (textRange, prop);
} // End applyOrRemoveChangeBar
Copy link to clipboard
Copied
Mine is working here, but yours looks good too.
Copy link to clipboard
Copied
@frameexpert - Yours looked good also, I was highly surprised it didn't work. Maybe I was using value somewhere else so it reset to "0" each time (seems unlikely, but ...). Anyway, all is good now!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now