automatically close a doc after user clicks on email send?

R

Reb

Hi All

I have a word form ready with the email header active in the document. When
I select Send on the email, the document remains open. I would like it
automatically close once the send button is hit. I found that the
ActiveWindow.EnvelopeVisible toggles the word email header.

I have got this far via the web but I really have no idea:

created a Class Module -clsobject:

Public WithEvents oApp As Word.Application

Private Sub oApp_DocumentChange()
' dunno what to put here
End Sub

created a module:

Dim oAppClass As New clsObject

Public Sub AutoExec()
Set oAppClass.oApp = Word.Application

If ActiveWindow.EnvelopeVisible = False Then
ActiveDocument.Close
End If

End Sub

Any ideas? Thanks in advance
 
D

Doug Robbins

In Word, if you create a macro with the name of one of Word's commands, that
macro will run in place of the built-in command. In this case, the name of
the macro needs to be FileSend().

See the second method in the article the article "How to send an email from
Word using VBA" at:

http://word.mvps.org/FAQs/InterDev/SendMail.htm


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
G

Guest

Hi

I created a macro called sub filesend() and followed the
links instructions. Running this macro creates a new
message and all the works but I couldnt get it to autorun
after pressing the FileSend comman is run. I would like it
to intercept the filesend event so that the
activedocument.close can run after the filesend has been
passed.

Thanks for your help.
 
D

Doug Robbins

Sorry, the macro should be named FileSendMail() That one runs when the
File>Send To>Mail Recipients as Attachment command is selected.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
G

Guest

Thanks Doug :)
-----Original Message-----
Sorry, the macro should be named FileSendMail() That one runs when the
File>Send To>Mail Recipients as Attachment command is selected.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP



.
 

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