Copy link to clipboard
Copied
I am trying to set the Page Numbering property of a book component using this script:
var book = app.ActiveBook;
var bookComp = book.FirstComponentInBook;
bookComp = bookComp.NextBookComponentInDFSOrder;
var compProps, i;
compProps= bookComp.GetProps();
i = GetPropIndex(compProps, Constants.FP_PageNumStyle);
compProps.propVal.ival = Constants.FV_PAGE_NUM_ROMAN_LC;
bookComp.SetProps(compProps);
When stepping through the script in debug it gets to the last line and then hangs forever and Framemaker becomes unresponsive.
I am able to change the PageNumStyle using this line:
bookComp.PageNumStyle = Constants.FV_PAGE_NUM_ROMAN_LC;
But that does not apply the setting to the component.
How do I apply the setting once I have changed it?
When setting these properties, it is not necessary to use GetProps ()/SetProps (); you can set the properties directly like you are doing in your second example. But as Jang says, you still have to invoke the Update method on the book to see the numbering take effect.
Copy link to clipboard
Copied
You need to execute the Update method on the Book object after making changes to the numbering. That is also true when you manually change the numbering - it might look like this is done immediately in the chapter you are setting the numbering properties for, but all the other chapters (and all the cross references, index entries, TOC) need to be updated also.
When updating the BookComponent, you are not actually changing the numbering that is stored in the file of the BookComponent itself, as the numbering in the Book may be different from the settings in the chapters. That is why you sometimes get a message stating that the numbering properties are inconsistent. Generating the Book output will normally take the numbering from the book as override to any numbering in the files that are part of the book. When you update the book, the numbering scheme (and style) you have set at the book component level will be applied to the chapter files.
4everJang
Copy link to clipboard
Copied
When setting these properties, it is not necessary to use GetProps ()/SetProps (); you can set the properties directly like you are doing in your second example. But as Jang says, you still have to invoke the Update method on the book to see the numbering take effect.
Copy link to clipboard
Copied
Thanks! This did the trick:
var book = app.ActiveBook;
var bookComp = book.FirstComponentInBook; //Cover
bookComp = bookComp.NextBookComponentInDFSOrder; //BP1
bookComp.PageNumStyle = Constants.FV_PAGE_NUM_ROMAN_LC;
bookComp.PageNumComputeMethod = Constants.FV_NUM_RESTART;
bookComp = bookComp.NextBookComponentInDFSOrder; //BP2
bookComp.PageNumStyle = Constants.FV_PAGE_NUM_ROMAN_LC;
bookComp.PageNumComputeMethod = Constants.FV_NUM_CONTINUE;
bookComp = bookComp.NextBookComponentInDFSOrder; //BP3
bookComp.PageNumStyle = Constants.FV_PAGE_NUM_ROMAN_LC;
bookComp.PageNumComputeMethod = Constants.FV_NUM_CONTINUE;
bookComp = bookComp.NextBookComponentInDFSOrder; //BP4
bookComp.PageNumStyle = Constants.FV_PAGE_NUM_ROMAN_LC;
bookComp.PageNumComputeMethod = Constants.FV_NUM_CONTINUE;
updateBookNumbering(book);
function updateBookNumbering(book) {
var updateParams, i;
updateParams= GetUpdateBookDefaultParams();
i = GetPropIndex(updateParams, Constants.FS_AllowInconsistentNumProps);
updateParams.propVal.ival = Constants.FV_DoOK;
i = GetPropIndex(updateParams, Constants.FS_UpdateBookNumbering);
updateParams.propVal.ival = true;
i = GetPropIndex(updateParams, Constants.FS_UpdateBookGeneratedFiles);
updateParams.propVal.ival = false;
i = GetPropIndex(updateParams, Constants.FS_UpdateBookMasterPages);
updateParams.propVal.ival = false;
i = GetPropIndex(updateParams, Constants.FS_UpdateBookOleLinks);
updateParams.propVal.ival = false;
i = GetPropIndex(updateParams, Constants.FS_UpdateBookTextReferences);
updateParams.propVal.ival = false;
i = GetPropIndex(updateParams, Constants.FS_UpdateBookXRefs);
updateParams.propVal.ival = false;
i = GetPropIndex(updateParams, Constants.FS_AlertUserAboutFailure);
updateParams.propVal.ival = false;
var returnp = new PropVals();
book.UpdateBook(updateParams, returnp);
}