Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Keith H Keith H is offline
external usenet poster
 
Posts: 1
Default create command button on word document to email me

How can I create a button that people can press that will email me the
document they are working on?
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default create command button on word document to email me

There are issues relating to whether your users will allow macros from third
party documents to run and what e-mail application they may be using,
neither of which are under your control, but the following macro will mail
the document to you by using Outlook

Sub SendDocumentAsAttachment()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
ActiveDocument.Save
End If

Set oOutlookApp = GetObject(, "Outlook.Application")
If Err 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
.To =
.Subject = "New subject" 'The message subject
.Body = "See attached document" ' The message body text
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue
.Send
End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub

http://www.gmayor.com/installing_macro.htm


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


Keith H wrote:
How can I create a button that people can press that will email me the
document they are working on?



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Attila Attila is offline
external usenet poster
 
Posts: 1
Default create command button on word document to email me

On Nov 13, 10:41 pm, "Graham Mayor" wrote:
There are issues relating to whether your users will allow macros from third
party documents to run and what e-mail application they may be using,
neither of which are under your control, but the following macro will mail
the document to you by using Outlook

Sub SendDocumentAsAttachment()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
ActiveDocument.Save
End If

Set oOutlookApp = GetObject(, "Outlook.Application")
If Err 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
.To =
.Subject = "New subject" 'The message subject
.Body = "See attached document" ' The message body text
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue
.Send
End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub

http://www.gmayor.com/installing_macro.htm

--

Graham Mayor - Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org


Keith H wrote:
How can I create a button that people can press that will email me the
document they are working on?


Hello Graham,
I tried the code and it gave me the following error:
---------------------------
Microsoft Visual Basic
---------------------------
Compile error:

User-defined type not defined
---------------------------
And the following line was highlighted: oOutlookApp As
Outlook.Application

I use Thunderbird2, maybe this is the problem. If it is indeed, could
you modify your script so I can use it with TB2?
Thank you
  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default create command button on word document to email me

Attila wrote:
Hello Graham,
I tried the code and it gave me the following error:
---------------------------
Microsoft Visual Basic
---------------------------
Compile error:

User-defined type not defined
---------------------------
And the following line was highlighted: oOutlookApp As
Outlook.Application

I use Thunderbird2, maybe this is the problem. If it is indeed, could
you modify your script so I can use it with TB2?
Thank you


In the vba editor, Tools References - ensure that the Microsoft Outlook
object library is checked, which should make the Outlook commands available.
I don't know anything about Thunderbird, or what functions its object
library brings to the table.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



  #5   Report Post  
simcha80 simcha80 is offline
Junior Member
 
Posts: 0
Default

Hi Graham,

I'm using Outlook and Word 2003, and all I'm trying to do is make a Submit button send the document, which is a form, as an attachment in an email.

The problem I'm having is that none of my code seems to execute at all.

I am familiar with VBA in MS Access.

I don't want to convert my form to a webform.

I've tried your code and it does nothing (not even an error message). I've also tried the RoutingSlip method, with the same results (nothing).

I've put in stop markers but nothing happens. I've also ensured my security settings are set to Low and to allow access to VBA Project.

Please help. Thanks, Simon.

Quote:
Originally Posted by Graham Mayor View Post
Attila wrote:
Hello Graham,
I tried the code and it gave me the following error:
---------------------------
Microsoft Visual Basic
---------------------------
Compile error:

User-defined type not defined
---------------------------
And the following line was highlighted: oOutlookApp As
Outlook.Application

I use Thunderbird2, maybe this is the problem. If it is indeed, could
you modify your script so I can use it with TB2?
Thank you


In the vba editor, Tools References - ensure that the Microsoft Outlook
object library is checked, which should make the Outlook commands available.
I don't know anything about Thunderbird, or what functions its object
library brings to the table.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Text on Command Button gone in email SueKuKu Microsoft Word Help 3 May 8th 06 11:55 PM
IS IT POSSIBLE TO CREATE A COMMAND BUTTON TO MAKE TIME STAMPS BCENTENO Microsoft Word Help 2 October 18th 05 06:22 AM
How do I create button to attach active document to an email? Mark_W Microsoft Word Help 2 October 11th 05 04:40 PM
Create a button that opens the default email app, and sends attach CatatonicBug Microsoft Word Help 0 October 4th 05 11:21 PM
want submit button to create reply email with filled out survey t. yummysandwich Microsoft Word Help 1 March 29th 05 10:35 PM


All times are GMT +1. The time now is 11:35 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"