Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
|
|||
|
|||
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:
|
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro Text on Command Button gone in email | Microsoft Word Help | |||
IS IT POSSIBLE TO CREATE A COMMAND BUTTON TO MAKE TIME STAMPS | Microsoft Word Help | |||
How do I create button to attach active document to an email? | Microsoft Word Help | |||
Create a button that opens the default email app, and sends attach | Microsoft Word Help | |||
want submit button to create reply email with filled out survey t. | Microsoft Word Help |