I've written an embarrassingly simple macro that cuts selected text from the active document and pastes it in another document (set off with stars and new lines so it is more visible) — basically a way to keep a record of text that I have edited out, but might want to reuse or come back to at some point in the future.

The macro assumes that I only have two documents open: the main one I'm editing and the one that holds all the scraps (the "cut" selections). The document that holds the scraps I always name "X -- " and then the same file name as the editing document".

Now the question: is there a way to have the macro automatically switch to the "X -- . . ." document, and then back to the main one so that I can keep more than these two documents open at a time? I'm sure that there is looking through the macro manual, but I suspect that given the macro virtuosity displayed on this forum it would be quicker to ask than to spend hours in what would likely be fruitless labour.

It works very well, but whenever there is a style in the original document that isn't in the "X -- " document, the macro interrupts to ask if I want to add or use the existing styles.

Does anyone know if there is a better way to use the paste command, than I have so far figured out, so that all the attributes of the original selection are always pasted into the X file and without being asked (or the macro interrupted)?

Also, is there anyway to ensure that the pasting will always be appended to the end of the document (sometimes I return to the X file to copy material back to the original, and don't remember to move the cursor to the bottom of the document)?

It works very well, but whenever there is a style in the original document that isn't in the "X -- " document, the macro interrupts to ask if I want to add or use the existing styles.

Does anyone know if there is a better way to use the paste command, than I have so far figured out, so that all the attributes of the original selection are always pasted into the X file and without being asked (or the macro interrupted)?

You'll need to use the Document object for the "X-" document to do the pasting. Oh, but actually, you'll need to bypass copy-paste, so you can use the "insert" command. Here's the snippet:

Lets say I work on an active document "myDocument" and I would like to put the scrappings into a new document (either to be called or to be newly created) with path "myDocumentScappings", in the same folder?

I find it a bit difficult, because calling the name of the active document comes with an ending, like .rtf. So I cannot simply append the string "Scrappings".

I was going to say that while Kino's find/replace expression works, you might be more comfortable working with NWP's explicit file path commands. But then I wrote up the equivalent code and it's much more tedious than I thought:

Good to have more than one solution for learning the language. thank you both

In fact I had been looking for something a bit more complicated: That the macro checks whether there is already a file with the desired new ending (like " ... myfile.scraps") in the same folder, and if not, creates one.

Who is online

Users browsing this forum: No registered users and 3 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum