A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Send Word doc attachment



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 16th 08, 02:52 PM posted to microsoft.public.outlook.program_vba
Chris
external usenet poster
 
Posts: 280
Default Send Word doc attachment

I'm a super novice with VBA, so please bear with my lack of knowledge. :-)
Using Word and Outlook 2003, and thanks to code offered in previous
discussions here, I have a Send Form command button on a Word form that opens
an Outlook message, pre-addressed, with a body text offering "Additional
comments:" The only problem is the Word document attachment icon (the
message opens in Rich Text format) is directly above the body text. Some
message recipients want to click directly next to the colon after "comments"
and begin to type. Naturally, the attachment icon is activated, and the
typed additional text pushes the icon across the message.

Is there any way to add a blank line between the icon and the beginning of
the body text? Or, is there a way to make the message format HTML so that
the attachment icon shows under the Subject line and not in the message body?
Would greatly appreciate any assistance.

The code I'm using:
Private Sub CommandButton1_Click()

Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document

Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
With EmailItem
.Subject = "Subject Title"
.Body = "Additional comments:"
.To = "
.Importance = olImportanceNormal 'Or olImprotanceHigh Or
olImprotanceLow
.Attachments.Add Doc.FullName
.Display
End With

Application.ScreenUpdating = True

Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing

End Sub

Ads
  #2  
Old May 16th 08, 08:53 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Send Word doc attachment


Depending on your Outlook version, you can set the EMailItem's BodyFormat
property to 2 (for HTM).

For a line break add vbCRLF.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool:
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Fri, 16 May 2008 06:52:01 -0700 schrieb Chris:

I'm a super novice with VBA, so please bear with my lack of knowledge.

:-)
Using Word and Outlook 2003, and thanks to code offered in previous
discussions here, I have a Send Form command button on a Word form that

opens
an Outlook message, pre-addressed, with a body text offering "Additional
comments:" The only problem is the Word document attachment icon (the
message opens in Rich Text format) is directly above the body text. Some
message recipients want to click directly next to the colon after

"comments"
and begin to type. Naturally, the attachment icon is activated, and the
typed additional text pushes the icon across the message.

Is there any way to add a blank line between the icon and the beginning of
the body text? Or, is there a way to make the message format HTML so that
the attachment icon shows under the Subject line and not in the message

body?
Would greatly appreciate any assistance.

The code I'm using:
Private Sub CommandButton1_Click()

Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document

Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
With EmailItem
.Subject = "Subject Title"
.Body = "Additional comments:"
.To = "
.Importance = olImportanceNormal 'Or olImprotanceHigh Or
olImprotanceLow
.Attachments.Add Doc.FullName
.Display
End With

Application.ScreenUpdating = True

Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing

End Sub

  #3  
Old May 17th 08, 12:42 AM posted to microsoft.public.outlook.program_vba
Chris
external usenet poster
 
Posts: 280
Default Send Word doc attachment

Thanks so much! The BodyFormat property did the trick. I didn't need to use
the line break. But for future information, where in the code would I add
vbCRLF, and would the line break be at the beginning of the body text or
after the attachment icon (if the message still was in Rich Text format)?

Since my original post, another issue has come up. The owner of the form
added a hyperlink to it (where it resides on a network server location) on an
intranet web page. He made the document read-only. By doing so, when a
person completed the form and clicked the Send Form command button, a Save As
dialog box displayed (because the code originally included the line
ActiveDocument.Save before the With EmailItem line). We removed this
ActiveDocument.Save from the code so that the macro would run and immediately
open an Outlook new message. Now, however, the attached document reverts to
being blank and does not contain the user's form field entries. If we leave
the ActiveDocument.Save line in the code, a SaveAs dialog box displays as
soon as the Send Form command button is clicked, confusing the form user. If
the document is not made read-only, and the ActiveDocument.Save line remains
in the code, the Send Form button works as it is supposed to, the Outlook
message displays in order to insert additional comments before sending, and
the message sends normally, and the attached document includes the filled out
form fields. The Word document remains displayed on the screen, however.
When closed, there is no Save reminder message box, and the user's form field
entries are saved back to the server location document. When the next user
activates the web page's hyperlink to it, the document does not open "clean"
but displays the previous user's entries.

As you can see, I now appear to be way out of my element. Thanking you in
advance for any help.

Chris

"Michael Bauer [MVP - Outlook]" wrote:


Depending on your Outlook version, you can set the EMailItem's BodyFormat
property to 2 (for HTM).

For a line break add vbCRLF.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool:
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Fri, 16 May 2008 06:52:01 -0700 schrieb Chris:

I'm a super novice with VBA, so please bear with my lack of knowledge.

:-)
Using Word and Outlook 2003, and thanks to code offered in previous
discussions here, I have a Send Form command button on a Word form that

opens
an Outlook message, pre-addressed, with a body text offering "Additional
comments:" The only problem is the Word document attachment icon (the
message opens in Rich Text format) is directly above the body text. Some
message recipients want to click directly next to the colon after

"comments"
and begin to type. Naturally, the attachment icon is activated, and the
typed additional text pushes the icon across the message.

Is there any way to add a blank line between the icon and the beginning of
the body text? Or, is there a way to make the message format HTML so that
the attachment icon shows under the Subject line and not in the message

body?
Would greatly appreciate any assistance.

The code I'm using:
Private Sub CommandButton1_Click()

Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document

Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
With EmailItem
.Subject = "Subject Title"
.Body = "Additional comments:"
.To = "
.Importance = olImportanceNormal 'Or olImprotanceHigh Or
olImprotanceLow
.Attachments.Add Doc.FullName
.Display
End With

Application.ScreenUpdating = True

Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing

End Sub


  #4  
Old May 20th 08, 04:41 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Send Word doc attachment



#1: You decide that yourself. If you add it to the beginning of the Body
then it will be exactly there.

#2: Frankly, I don't know what you're talking about.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool:
: http://www.vboffice.net/product.html?pub=6&lang=en



Am Fri, 16 May 2008 16:42:02 -0700 schrieb Chris:

Thanks so much! The BodyFormat property did the trick. I didn't need to

use
the line break. But for future information, where in the code would I add
vbCRLF, and would the line break be at the beginning of the body text or
after the attachment icon (if the message still was in Rich Text format)?

Since my original post, another issue has come up. The owner of the form
added a hyperlink to it (where it resides on a network server location) on

an
intranet web page. He made the document read-only. By doing so, when a
person completed the form and clicked the Send Form command button, a Save

As
dialog box displayed (because the code originally included the line
ActiveDocument.Save before the With EmailItem line). We removed this
ActiveDocument.Save from the code so that the macro would run and

immediately
open an Outlook new message. Now, however, the attached document reverts

to
being blank and does not contain the user's form field entries. If we

leave
the ActiveDocument.Save line in the code, a SaveAs dialog box displays as
soon as the Send Form command button is clicked, confusing the form user.

If
the document is not made read-only, and the ActiveDocument.Save line

remains
in the code, the Send Form button works as it is supposed to, the Outlook
message displays in order to insert additional comments before sending,

and
the message sends normally, and the attached document includes the filled

out
form fields. The Word document remains displayed on the screen, however.
When closed, there is no Save reminder message box, and the user's form

field
entries are saved back to the server location document. When the next

user
activates the web page's hyperlink to it, the document does not open

"clean"
but displays the previous user's entries.

As you can see, I now appear to be way out of my element. Thanking you in
advance for any help.

Chris

"Michael Bauer [MVP - Outlook]" wrote:


Depending on your Outlook version, you can set the EMailItem's BodyFormat
property to 2 (for HTM).

For a line break add vbCRLF.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool:
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Fri, 16 May 2008 06:52:01 -0700 schrieb Chris:

I'm a super novice with VBA, so please bear with my lack of knowledge.

:-)
Using Word and Outlook 2003, and thanks to code offered in previous
discussions here, I have a Send Form command button on a Word form that

opens
an Outlook message, pre-addressed, with a body text offering "Additional
comments:" The only problem is the Word document attachment icon (the
message opens in Rich Text format) is directly above the body text.

Some
message recipients want to click directly next to the colon after

"comments"
and begin to type. Naturally, the attachment icon is activated, and the
typed additional text pushes the icon across the message.

Is there any way to add a blank line between the icon and the beginning

of
the body text? Or, is there a way to make the message format HTML so

that
the attachment icon shows under the Subject line and not in the message

body?
Would greatly appreciate any assistance.

The code I'm using:
Private Sub CommandButton1_Click()

Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document

Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
With EmailItem
.Subject = "Subject Title"
.Body = "Additional comments:"
.To = "
.Importance = olImportanceNormal 'Or olImprotanceHigh Or
olImprotanceLow
.Attachments.Add Doc.FullName
.Display
End With

Application.ScreenUpdating = True

Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing

End Sub


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I can send email with attachment receiver cannot open attachment saffi Outlook - General Queries 8 December 5th 07 10:06 AM
Word (.doc) attachment opens Excel instead of Word Suzy-Q Outlook Express 2 May 22nd 07 06:38 PM
a 10 k word doc attachment save as ...become 13M itcom Outlook - Installation 1 March 15th 07 04:39 AM
Howto save Word attachment? Deon Outlook - General Queries 4 February 7th 07 06:00 AM
printing attachment name in Word Martin Outlook - Using Forms 2 April 7th 06 10:46 AM


All times are GMT +1. The time now is 06:22 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.