Hello Allen,
Okay. Now I understand better what you are trying to achieve.
It might be good to keep some terms clear. One of the advantages of Nisus Writer is that it can work with
Attributed Text, text with styling attributes. I prefer to reserve the term
Styles for Character/Paragraph styles, which are one kind of attribute that can be used to define combinations of styling attibutes. Text without styling attributes ("plain text") can be called
Strings.
Now it seems what you want to do is the exact reverse of what I understood originally: you want to
keep the attributes, and
get rid of the styles, so that the pasted text takes on the styles of the target document, but nevertheless keeps the extra added salient attributes (e.g., bolding, etc.). This is incidentally a general problem, that arises in any copy/paste operation. Judging by your mentioning "use existing styles" you are pasting text which has a style with the same name, but different attributes, where Nisus throws up a style conflict dialog.
But here is the amazing thing: if you transfer a bit of text from Document A with attributes and styles to Document B which has styles with the same name but different attributes on those styles, the transferred text will take on the new style with its attendant attributes. Here is what the macro code will look like:
Code: Select all
$sourceDoc = Document.withDisplayName 'Document A.rtf'
$targetDoc = Document.withDisplayName 'Document B.rtf'
$sourceSel = $sourceDoc.textSelection
$sourceText = $sourceSel.subtext
$targetSel = $targetDoc.textSelection
$targetDoc.text.replaceInRange $targetSel.range, $sourceText
How you build this into your macro will depend a bit. How are you transferring the text? Is the macro just supposed to select one bit, or many? If it's the latter, how does it know which bit will go where?
If you still have questions, and need help, just let me know.