Reply
 
Thread Tools Display Modes
  #1   Report Post  
Hans
 
Posts: n/a
Default Add code to select email field in mailmerge!

Is it possible to add a macro inside a dot file than when doing a mailmerge
will select the correct email field so the user don't have to select which
is the email field manually? I have a program that generates a tab separated
text file with data and opens the dot file and do the actual mailmerge.

What is missing is the automation to send the emails and this also includes
selecting which field is the email address (for my template I know which
field contains the email address).

Ideally a solution working for Win2000 and higher would be best but if there
are functionality in office XP or 2003 that makes this task easier please
let me know.

Regards
/Hans


  #2   Report Post  
Doug Robbins
 
Posts: n/a
Default

Here's a Macro to extract all of the email addresses from a document, but
you would probably be better off to modify the technique used in the article
"Mail Merge to E-mail with Attachments" at

http://word.mvps.org/FAQs/MailMerge/...ttachments.htm


Sub CopyAddressesToOtherDoc()


Dim Source As Document, Target As Document, myRange As Range
Set Source = ActiveDocument
Set Target = Documents.Add

Application.ScreenUpdating = False

Source.Activate
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(findText:="[+0-9A-z._-]{1,}\@[A-z.]{1,}", _
MatchWildcards:=True, Wrap:=wdFindStop, Forward:=True) = True
Set myRange = Selection.Range
Target.Range.InsertAfter myRange & vbCr
Loop
End With

Selection.HomeKey Unit:=wdStory
Target.Activate

End Sub

--
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
"Hans" wrote in message
...
Is it possible to add a macro inside a dot file than when doing a
mailmerge
will select the correct email field so the user don't have to select which
is the email field manually? I have a program that generates a tab
separated
text file with data and opens the dot file and do the actual mailmerge.

What is missing is the automation to send the emails and this also
includes
selecting which field is the email address (for my template I know which
field contains the email address).

Ideally a solution working for Win2000 and higher would be best but if
there
are functionality in office XP or 2003 that makes this task easier please
let me know.

Regards
/Hans




  #3   Report Post  
Hans
 
Posts: n/a
Default

Thanks Doug for your help but I think I was unclear what I want to do.



I have an application that creates a tab separated file (lets call this
data.txt) where one column contains the email address. The application opens
the template file and the template reads the data.txt file. If they want to
mail this document they can click the "Merge to Email" button but then you
would have to select which field is the email field. I wonder if it is
possible to add macro code so they don't need to click on the "Merge to
Email" button where you manually have to select the email field, enter a
subject and click OK). Ideally it should



1. select the correct email field automatically (I know the name of the
column that contains the email address )

2. Set a subject (ideally they would like to have dynamic merge instructions
in the subject as well to customize the subject line for every email. For
example add the contact name which is also part of the data.txt file. Is it
possible to have mailmerge instructions in the subject?)

3. Do the actual send.



Either this could be executed in an event (open) or maybe a button could be
created that will do step 1-3 automatically. I know this sounds silly but
they think 3-4 clicks is too much to do. They want single click
functionality.



I guess I can solve this by following the steps in the URL you sent but it
seems to be overkill in this case.


Regards
/Hans

P.s Sorry for my english but I guess it is better than your swedish :-) D.s


  #4   Report Post  
Doug Robbins
 
Posts: n/a
Default

I understood exactly what you want to do and the information that I posted
should give you a few ideas about how to go about it.

--
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
"Hans" wrote in message
...
Thanks Doug for your help but I think I was unclear what I want to do.



I have an application that creates a tab separated file (lets call this
data.txt) where one column contains the email address. The application
opens
the template file and the template reads the data.txt file. If they want
to
mail this document they can click the "Merge to Email" button but then you
would have to select which field is the email field. I wonder if it is
possible to add macro code so they don't need to click on the "Merge to
Email" button where you manually have to select the email field, enter a
subject and click OK). Ideally it should



1. select the correct email field automatically (I know the name of the
column that contains the email address )

2. Set a subject (ideally they would like to have dynamic merge
instructions
in the subject as well to customize the subject line for every email. For
example add the contact name which is also part of the data.txt file. Is
it
possible to have mailmerge instructions in the subject?)

3. Do the actual send.



Either this could be executed in an event (open) or maybe a button could
be
created that will do step 1-3 automatically. I know this sounds silly but
they think 3-4 clicks is too much to do. They want single click
functionality.



I guess I can solve this by following the steps in the URL you sent but it
seems to be overkill in this case.


Regards
/Hans

P.s Sorry for my english but I guess it is better than your swedish :-)
D.s




  #5   Report Post  
Hans
 
Posts: n/a
Default

Hi Doug!

Ok I guess I will have to look deeper into your example. I was hoping this
was a three line macro. The dialog where you select the field containing the
email addrss, setting the subject and then send the emails looks like two
property settings to me and one call to a method send so I was hoping it was
possible to set these programtically (the properties and method below don't
exist but I was hoping that they do exist but maybe with another name).

Mydocument.active_email_property =
"my_mailmerge_field_containing_email_address "
Mydocument.subject_for_email = "Some subject"
Mydocument.send

Thanks for your help!
Regards
/Hans


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
Field code error when printing document Olga Microsoft Word Help 1 January 25th 05 07:59 PM
Date Field Code problems TC Mailmerge 3 December 29th 04 11:17 PM
How do I use the PRINT field code to ... Dave Microsoft Word Help 3 December 13th 04 04:06 PM
Using MAILMERGE fields within HYPERLINK fields for Merge to Email Mark V Mailmerge 2 December 4th 04 05:01 PM
how do i select email recipeints in microsoft word gerald dembo New Users 1 November 29th 04 12:28 AM


All times are GMT +1. The time now is 09:16 PM.

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"