Cloning document content to new docs

  • Thread starter Eric Legault [MVP - Outlook]
  • Start date
E

Eric Legault [MVP - Outlook]

I'm using the Word Object Model to work with the body of a new e-mail
message in Outlook 2007. My goal is to simply clone the active e-mail into
one or more copies (the recipients from the source will each get their own
copy of the original, which will be trashed). I'm tried using
Document.Select, then Application.Copy on the source e-mail, followed by
Document.Activate, Document.Select (the Document objects are specific to the
cloned item, not the source), Application.Selection.WholeStory and then
Application.Selection.PasteAndFormat(wdPasteDefault) on each newly cloned
e-mail. However, there are times when I get a locked for editing warning
and the cloning fails - empty message body; this occurs inconsistently.

Is there a better approach to cloning the contents of a Document object in
situations like this where the documents are not file based?

--
Eric Legault [MVP - Outlook]
MCDBA, MCTS (Messaging & Collaboration, SharePoint Infrastructure, MOSS 2007
& WSS 3.0 Application Development)
President
Collaborative Innovations
-> Try Picture Attachments Wizard 2.0 For Microsoft Outlook <-
-> Take your SharePoint content offline <-
-> More info: http://www.collaborativeinnovations.ca <-
Blog: http://blogs.officezealot.com/legault
 
T

Tony Jollans

If you have the Document (WordEditor) object in Outlook 2007 you should be
able to work with the document like any other - regardless of whether it
exists on disc. Not sure from what you say what might cause a locked error.

You should neither need to Select, nor Activate, any Documents if you have
references to them. Document1.Content.Copy followed by Document2.Range.Paste
should be sufficient for most purposes. Or even avoiding the clipboard:
Document2.Range.InsertAfter Document1.Range

But ... I don't quite follow what you are doing. Why do you want to create
multiple copies at source? Won't a single copy get replicated when you send
it?
 
E

Eric Legault [MVP - Outlook]

Thanks Tony, I'll try those methods.

The process is the user creates one e-mail and inserts all To, Cc and Bcc
recipients. The user clicks a button and the code then creates a separate
e-mail for each recipient and kills the original. There's special unique
URLs on hyperlinked text that's generated within each of those e-mails that
track which user clicked them.

--
Eric Legault [MVP - Outlook]
MCDBA, MCTS (Messaging & Collaboration, SharePoint Infrastructure, MOSS 2007
& WSS 3.0 Application Development)
Collaborative Innovations
NEW! -> Try Picture Attachments Wizard 2.0 For Microsoft Outlook <-
Web: http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault


Tony Jollans said:
If you have the Document (WordEditor) object in Outlook 2007 you should be
able to work with the document like any other - regardless of whether it
exists on disc. Not sure from what you say what might cause a locked
error.

You should neither need to Select, nor Activate, any Documents if you have
references to them. Document1.Content.Copy followed by
Document2.Range.Paste should be sufficient for most purposes. Or even
avoiding the clipboard: Document2.Range.InsertAfter Document1.Range

But ... I don't quite follow what you are doing. Why do you want to create
multiple copies at source? Won't a single copy get replicated when you
send it?

--
Enjoy,
Tony

Eric Legault said:
I'm using the Word Object Model to work with the body of a new e-mail
message in Outlook 2007. My goal is to simply clone the active e-mail
into one or more copies (the recipients from the source will each get
their own copy of the original, which will be trashed). I'm tried using
Document.Select, then Application.Copy on the source e-mail, followed by
Document.Activate, Document.Select (the Document objects are specific to
the cloned item, not the source), Application.Selection.WholeStory and
then Application.Selection.PasteAndFormat(wdPasteDefault) on each newly
cloned e-mail. However, there are times when I get a locked for editing
warning and the cloning fails - empty message body; this occurs
inconsistently.

Is there a better approach to cloning the contents of a Document object
in situations like this where the documents are not file based?

--
Eric Legault [MVP - Outlook]
MCDBA, MCTS (Messaging & Collaboration, SharePoint Infrastructure, MOSS
2007 & WSS 3.0 Application Development)
President
Collaborative Innovations
-> Try Picture Attachments Wizard 2.0 For Microsoft Outlook <-
-> Take your SharePoint content offline <-
-> More info: http://www.collaborativeinnovations.ca <-
Blog: http://blogs.officezealot.com/legault
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top