Bonjour a tous,
je souhaiterai realiser un mail merge a partir d'un script vb, j'ai donc suivit l'exemple de microsoft: http://support.microsoft.com/kb/285332 et modifier pour en faire un script. Seulement ca ne marche pas, il me mets tjrs l'erreur: expected statement lorsque j'ouvre les dataSource. Ci dessous le code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 
Function IPFaxMerge()
 
  Dim oApp 'As Word.Application
  Dim oMainDoc 'As Word.Document
  Dim oSel 'As Word.Selection
  Dim sDBPath 'as String
 
  'Start Word
  Set oApp = CreateObject("Word.Application")
  Set oMainDoc = oApp.Documents.Add
 
  With oMainDoc.MailMerge
 
        .MainDocumentType = wdFormLetters
 
        'Set up the mail merge data source to Northwind.mdb.
        sDBPath = "C:\Program Files\Microsoft Office\" & _
                  "OfficeXP\Samples\Northwind.mdb"
 
        .OpenDataSource Name:=sDBPath, _
           SQLStatement:="SELECT * FROM [Customers]"
 
        'Add the field codes to the document to create the form letter.
        With .Fields
            Set oSel = oApp.Selection
            .Add oSel.Range, "CompanyName"
            oSel.TypeParagraph
            .Add oSel.Range, "Address"
            oSel.TypeParagraph
            .Add oSel.Range, "City"
            oSel.TypeText ", "
            .Add oSel.Range, "Country"
            oSel.TypeParagraph
            oSel.TypeParagraph
            oSel.TypeText "Dear "
            .Add oSel.Range, "ContactName"
            oSel.TypeText ","
            oSel.TypeParagraph
            oSel.TypeParagraph
            oSel.TypeText " This letter is to inform you..."
            oSel.TypeParagraph
            oSel.TypeParagraph
            oSel.TypeText "Sincerely, [Your Name Here]"
        End With
    End With
 
    'Perform the mail merge to a new document.
    With oMainDoc
        .MailMerge.Destination = wdSendToNewDocument
        .MailMerge.Execute Pause:=False
    End With
 
 
End Function
 
 
' *** MAIN **************************************   
Call IPFaxMerge()

merci de votre aide