Accessing a mailmerge field from vba 
Author Message
 Accessing a mailmerge field from vba

Hello,

I am trying to access a field within a documents mailmerge file using
VBA,  I am not having much luck, could somebody please tell me how to
access fields within the mailmerge file.

The code I have is below.

Thanks in advance.

    Selection.GoTo what:=wdGoToBookmark, Name:="bookByFax"
    If obByFax.Value = True Then
        Dim fax As String
        fax = ActiveDocument.MailMerge.Fields(19)
        Selection.TypeText "By fax " & fax
    ElseIf obConfidential.Value = True Then
        Selection.TypeText "Confidential"
    End If



Fri, 29 Jul 2005 18:10:04 GMT  
 Accessing a mailmerge field from vba
At what point in the merge process are you trying to execute your code? I
couldn't really work out exactly what you want to happen.

It's important to realise that there are really two types of fiedls during a
merge - the Word { MERGEFIELD } fields, which do not have a value (or
probably not the one you want) before the merge is performed, and the fields
in the data source, whose values you can get from the Mailmerge.Datasource
object.

--
Peter Jamieson
MS Word MVP


Quote:
> Hello,

> I am trying to access a field within a documents mailmerge file using
> VBA,  I am not having much luck, could somebody please tell me how to
> access fields within the mailmerge file.

> The code I have is below.

> Thanks in advance.

>     Selection.GoTo what:=wdGoToBookmark, Name:="bookByFax"
>     If obByFax.Value = True Then
>         Dim fax As String
>         fax = ActiveDocument.MailMerge.Fields(19)
>         Selection.TypeText "By fax " & fax
>     ElseIf obConfidential.Value = True Then
>         Selection.TypeText "Confidential"
>     End If



Sat, 30 Jul 2005 10:35:30 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Checking Word Mailmerge status from Access VBA

2. accessing word97 MailMerge fields in HEADER

3. VBA - Access 2000 Create a table and access the fields

4. mailmerge fields in the header/footer do not appear in the mailmerge.fields (Bug?)

5. Automating MailMerge with VBA

6. Mailmerge a word document through VBA

7. >10000 lines Excel - MailMerge with word via VBA Macro

8. VBA Mailmerge subjectline

9. Mailmerge a word document through VBA

10. Word/Excel Mailmerge via VBA macro problem

11. Sending a mailmerge via e-mail using VBA

12. Questions about MailMerge using VBA

 

 
Powered by phpBB® Forum Software