Home Forums General XMetaL Discussion slow range.select() for large Document Reply To: slow range.select() for large Document

Derek Read

Reply to: slow range.select() for large Document

Range objects are normally hidden and do not cause the document to be updated when moving them around, however, as soon as you make a modification to the document the formatter (the code that draws the document on the screen) runs to update what the user is viewing.

Range.Select() also forces the formatter to run because the selection is made visible.

Depending on what you are doing you may wish to try turning off formatting entirely until whatever your script is doing has completed. This is done using the API ActiveDocument.FormattingUpdating=boolean

Be careful with this API because if you leave it set to false XMetaL will continue to not update what the user sees on screen and they will see odd behaviour when they begin typing or interacting with the document. So, make sure you catch any exceptions and test your code well.