Earlier in CS2 I used to be able to tag selected text with the “markup” method. It was simple and worked placing tag markers around the highlighted text. However with CS4 I receive the error… "Can not change the element to be associated with this object. Try creating a new element." Can anybody help me out?
It's passed 6 days. Could anybody help me here, please?
"markup" is still a valid method for selections in CS4. I think your error might be caused by the fact that a single word (or characher or whatever) can not be tagged without its container being tagged as well. You can see that if you make the same thing "by hand".
If you make sure that the container object, your textframe, is tagged before tagging the selection, it seems to work.
My test code:
var myWord = app.selection.getElements(); myXmlStoryElem=app.activeDocument.xmlElements.item(0).xmlElements.add("Story"); myWord.parentStory.markup(myXmlStoryElem); myXmlSelectionElem=myXmlStoryElem.xmlElements.add("test"); myWord.markup(myXmlSelectionElem);