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

Add Multiple Attachments Sources using VBA in Word



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 29th 09, 03:55 PM posted to microsoft.public.outlook.program_vba
JBark
external usenet poster
 
Posts: 6
Default Add Multiple Attachments Sources using VBA in Word

Hi,

How can this code be written to add multiple attachments using vba and Word
as my email editor. The first attachment is the active document itself, the
other 4 attachments have their full path names stored in a field in the
document. This is what I have but I'm getting a syntax error and I'm not sure
why. Any suggestions are greatly appreciated.


.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile1").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile2").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile3").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile4").Res ult,
Type:=olByValue
.Send

Ads
  #2  
Old June 29th 09, 04:31 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Add Multiple Attachments Sources using VBA in Word

You need a separate .Attachments.Add statement for each attachment, not one
long statement with multiple calls to the .Add method.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"JBark" wrote in message
...
Hi,

How can this code be written to add multiple attachments using vba and
Word
as my email editor. The first attachment is the active document itself,
the
other 4 attachments have their full path names stored in a field in the
document. This is what I have but I'm getting a syntax error and I'm not
sure
why. Any suggestions are greatly appreciated.


.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile1").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile2").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile3").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile4").Res ult,
Type:=olByValue
.Send



  #3  
Old June 29th 09, 04:52 PM posted to microsoft.public.outlook.program_vba
JBark
external usenet poster
 
Posts: 6
Default Add Multiple Attachments Sources using VBA in Word

Yes - I had tried that also like this, but I'm still getting syntax error.

.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
.Attachments.Add Source:=ActiveDocument.TextBox("TextBoxFile1").Res ult,
Type:=olByValue, _
.Attachments.Add Source:=ActiveDocument.TextBox("TextBoxFile2").Res ult,
Type:=olByValue, _
.Attachments.Add Source:=ActiveDocument.TextBox("TextBoxFile3").Res ult,
Type:=olByValue, _
.Attachments.Add Source:=ActiveDocument.TextBox("TextBoxFile4").Res ult,
Type:=olByValue
.Send

"Sue Mosher [MVP]" wrote:

You need a separate .Attachments.Add statement for each attachment, not one
long statement with multiple calls to the .Add method.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"JBark" wrote in message
...
Hi,

How can this code be written to add multiple attachments using vba and
Word
as my email editor. The first attachment is the active document itself,
the
other 4 attachments have their full path names stored in a field in the
document. This is what I have but I'm getting a syntax error and I'm not
sure
why. Any suggestions are greatly appreciated.


.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile1").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile2").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile3").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile4").Res ult,
Type:=olByValue
.Send




  #4  
Old June 29th 09, 05:26 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Add Multiple Attachments Sources using VBA in Word

This is still all one statement, because of the underscore continuation
characters at the end of the first four lines.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"JBark" wrote in message
...
Yes - I had tried that also like this, but I'm still getting syntax error.

.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
.Attachments.Add Source:=ActiveDocument.TextBox("TextBoxFile1").Res ult,
Type:=olByValue, _
.Attachments.Add Source:=ActiveDocument.TextBox("TextBoxFile2").Res ult,
Type:=olByValue, _
.Attachments.Add Source:=ActiveDocument.TextBox("TextBoxFile3").Res ult,
Type:=olByValue, _
.Attachments.Add Source:=ActiveDocument.TextBox("TextBoxFile4").Res ult,
Type:=olByValue
.Send

"Sue Mosher [MVP]" wrote:

You need a separate .Attachments.Add statement for each attachment, not
one
long statement with multiple calls to the .Add method.

"JBark" wrote in message
...
Hi,

How can this code be written to add multiple attachments using vba and
Word
as my email editor. The first attachment is the active document itself,
the
other 4 attachments have their full path names stored in a field in the
document. This is what I have but I'm getting a syntax error and I'm
not
sure
why. Any suggestions are greatly appreciated.


.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile1").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile2").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile3").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile4").Res ult,
Type:=olByValue
.Send







  #5  
Old June 29th 09, 06:25 PM posted to microsoft.public.outlook.program_vba
JBark
external usenet poster
 
Posts: 6
Default Add Multiple Attachments Sources using VBA in Word

Thanks Sue. The code runs fine without any errors and attaches the original
doc but not the additional docs. Should I ask someone over in the Word Forum
about this? Or do you have a suggestion as to why the additional files will
not attach?
  #6  
Old June 29th 09, 06:33 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Add Multiple Attachments Sources using VBA in Word

If you have already made the change I suggested -- removing the extraneous
underscore characters so that you have each Attachments.Add call in a
separate statement -- I would suggest looking at the actual value of what
you're getting from the ActiveDocument.TextBox("TextBoxFile1").Result
expressions.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"JBark" wrote in message
...
Thanks Sue. The code runs fine without any errors and attaches the
original
doc but not the additional docs. Should I ask someone over in the Word
Forum
about this? Or do you have a suggestion as to why the additional files
will
not attach?


"Sue Mosher [MVP]" wrote in message
...
This is still all one statement, because of the underscore continuation
characters at the end of the first four lines.


"JBark" wrote in message
...
Yes - I had tried that also like this, but I'm still getting syntax
error.

.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
.Attachments.Add
Source:=ActiveDocument.TextBox("TextBoxFile1").Res ult,
Type:=olByValue, _
.Attachments.Add
Source:=ActiveDocument.TextBox("TextBoxFile2").Res ult,
Type:=olByValue, _
.Attachments.Add
Source:=ActiveDocument.TextBox("TextBoxFile3").Res ult,
Type:=olByValue, _
.Attachments.Add
Source:=ActiveDocument.TextBox("TextBoxFile4").Res ult,
Type:=olByValue
.Send

"Sue Mosher [MVP]" wrote:

You need a separate .Attachments.Add statement for each attachment, not
one
long statement with multiple calls to the .Add method.

"JBark" wrote in message
...
Hi,

How can this code be written to add multiple attachments using vba and
Word
as my email editor. The first attachment is the active document
itself,
the
other 4 attachments have their full path names stored in a field in
the
document. This is what I have but I'm getting a syntax error and I'm
not
sure
why. Any suggestions are greatly appreciated.


.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue,
_
.Add Source:=ActiveDocument.TextBox("TextBoxFile1").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile2").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile3").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile4").Res ult,
Type:=olByValue
.Send



  #7  
Old June 29th 09, 08:12 PM posted to microsoft.public.outlook.program_vba
JBark
external usenet poster
 
Posts: 6
Default Add Multiple Attachments Sources using VBA in Word

Yes - I kept digging and I was declaring the fields as formfields but they're
really textboxes. It works now like this:

..Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue
.Attachments.Add Source:=ActiveDocument.TextBoxFile1.Value,
Type:=olByValue
.Attachments.Add Source:=ActiveDocument.TextBoxFile2.Value,
Type:=olByValue
.Attachments.Add Source:=ActiveDocument.TextBoxFile3.Value,
Type:=olByValue
.Attachments.Add Source:=ActiveDocument.TextBoxFile4.Value,
Type:=olByValue
.Send

Thanks a bunch for your help!

"Sue Mosher [MVP]" wrote:

If you have already made the change I suggested -- removing the extraneous
underscore characters so that you have each Attachments.Add call in a
separate statement -- I would suggest looking at the actual value of what
you're getting from the ActiveDocument.TextBox("TextBoxFile1").Result
expressions.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"JBark" wrote in message
...
Thanks Sue. The code runs fine without any errors and attaches the
original
doc but not the additional docs. Should I ask someone over in the Word
Forum
about this? Or do you have a suggestion as to why the additional files
will
not attach?


"Sue Mosher [MVP]" wrote in message
...
This is still all one statement, because of the underscore continuation
characters at the end of the first four lines.


"JBark" wrote in message
...
Yes - I had tried that also like this, but I'm still getting syntax
error.

.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
.Attachments.Add
Source:=ActiveDocument.TextBox("TextBoxFile1").Res ult,
Type:=olByValue, _
.Attachments.Add
Source:=ActiveDocument.TextBox("TextBoxFile2").Res ult,
Type:=olByValue, _
.Attachments.Add
Source:=ActiveDocument.TextBox("TextBoxFile3").Res ult,
Type:=olByValue, _
.Attachments.Add
Source:=ActiveDocument.TextBox("TextBoxFile4").Res ult,
Type:=olByValue
.Send

"Sue Mosher [MVP]" wrote:

You need a separate .Attachments.Add statement for each attachment, not
one
long statement with multiple calls to the .Add method.

"JBark" wrote in message
...
Hi,

How can this code be written to add multiple attachments using vba and
Word
as my email editor. The first attachment is the active document
itself,
the
other 4 attachments have their full path names stored in a field in
the
document. This is what I have but I'm getting a syntax error and I'm
not
sure
why. Any suggestions are greatly appreciated.


.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue,
_
.Add Source:=ActiveDocument.TextBox("TextBoxFile1").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile2").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile3").Res ult,
Type:=olByValue, _
.Add Source:=ActiveDocument.TextBox("TextBoxFile4").Res ult,
Type:=olByValue
.Send




 




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
Cannot remove defunct Contacts sources Anteaus Outlook - Using Contacts 2 March 14th 09 08:26 AM
I RECEIVE SEVERAL OF THE SAME EMAIL FROM DIFFERENT SOURCES CBURD Outlook Express 0 January 11th 08 10:23 PM
Word attachments in Outlook Accept Creditcards on website Outlook - Installation 11 August 6th 07 03:57 PM
help needed, pls, with trusted sources Uncle Vinnie Outlook - General Queries 3 February 28th 07 02:35 PM
How to direct output from Word mail merge to multiple Word documents [email protected] Outlook - General Queries 3 August 11th 06 04:10 AM


All times are GMT +1. The time now is 02:03 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.