Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save unsaved doc, without saving it 1

Status
Not open for further replies.

JanAmdiLetvad

Programmer
Sep 3, 2010
3
DK
Hi

I want to mail the active Word document as an attachment, using CDO.Message.
Therefore I have to save the document, so I can attach the doc-file to the mail.
So far so good.
But because the document is an unsaved document to start with, I want to keep the document unsaved to the user.
But how can i keep the document unsaved, an still use it as an attachment?
I'm using Word 2003

Thanks in advance

Jan Amdi Letvad
 
Hi Jan,

In short, you can't. That's because the mailmerge app needs to attach an actual copy of the file that it can read from disk. Of course, if you're using vba, you could simply use it to delete the file after the emailing has finished. the user need never be aware of what's going on behind the scenes.


Cheers
[MS MVP - Word]
 
What about this ?
ActiveDocument.Saved = False

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hmmmm.....it's close, but not exactly what i need.
The senario is as follow:
The user creates the letter in Word, and it's still not saved anywhere.
The user then mails the document, using my CDO.Message application.
But then the user ends up with a document in Word, that is now saved as at temporary file - the file I attached to the mail.
The user should end up with a document, that hasent been saved. Just like if you are using the "Sent to" i Word, and Outlook puts a copy of the file in the mail, but the document is still untouched i Word.
So I need to save the document to a file, without the user knowing it - if that's possible :)
 
Outlook puts a copy of the file in the mail,
Why not do exactly this?

==>
Code:
Dim tmp As Document, act As Document
Set act = ActiveDocument
Set tmp = New Document
tmp.Range = act.Range
tmp.SaveAs "C:\tmp.doc", wdFormatDocument
tmp.Close

'now attach your tmp doc

Kill "C:\tmp.doc"

You have attached a copy of the doc, the original doc is still untouched and unsaved...

;-)

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Remark:
the above is Word VBA. You might have to adapt the code slightly, like adding
Code:
Dim Wrd as Word.Application
and
Code:
Set act = Wrd.ActiveDocument

or the like.

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Conversely, you can use the SendMail method and let Word use its default methodology

Code:
Application.SendMail

Unfortunately it takes no arguments, so you can't define a "To" or a "CC" or "Bcc" or a subject
 
The OP has stated:

"The user then mails the document, using my CDO.Message application."

Not Outlook. Not Word SendMail.

Gerry

Och ammmmm, I think I need a shave.
- hirsute Scot, trying to decide
 
It is either Collaboration Data Objects, which does use Outlook...

OR, it is ASP CDO

here is also a decent page about using CDO.

And the Microsoft offical site.

There is also a good thread here at TT.

As is noted on one of the sites, CDO is not available with Outlook 2007, and is likely on its way out, as is.

Basically it is a way of using SMTP directly.

Gerry

Och ammmmm, I think I need a shave.
- hirsute Scot, trying to decide
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top