MailMerge with Variable InlineShape

A

Alex St-Pierre

Hi!
I would like to make a mailmerge with an InlineShape that vary depending of
a mergefield. Also, I'm wondering if there is a way to put records 1-100 in
the same word file,101-200, etc..?
Thank you!
Alex

Sub MailMergeWithInlineShape()
Dim appWord As Word.Application
Dim docWord1 As Word.Document
Dim oChart As Graph.Chart

Dim c As Long
Set appWord = Word.Application
Set docWord1 = appWord.ActiveDocument

With docWord1
.InlineShapes(1).OLEFormat.Activate
Set oChart = .InlineShapes(1).OLEFormat.Object
End With

For i = 1 To 1000
With docWord1.mailmerge
.Destination = wdSendToNewDocument
With .DataSource
.FirstRecord = i
.LastRecord = i
End With

oChart.Application.DataSheet.Range("A1").Value =
..Fields("actions mondiales")
oChart.Application.DataSheet.Range("A2").Value =
..Fields("obligations canadiennes")

.Execute Pause:=False
End With
Next i

Set oChart = Nothing
Set docWord1 = Nothing
Set appWord = Nothing
End Sub
 
J

Jean-Guy Marcil

Alex St-Pierre said:
Hi!
I would like to make a mailmerge with an InlineShape that vary depending of
a mergefield. Also, I'm wondering if there is a way to put records 1-100 in

From the code you posted, it is hard to tell you how... Where are those
inlineshapes from? What type of inlineshapes shape (Autoshapes, pictures,
etc.)? What is the logic the code should use... The Word version might also
be important...
the same word file,101-200, etc..?

Just use a double loop:


Dim i As Long
Dim k As Long

i = 1
k = 0
Do While i <= 1000
'Create Document
k = k + 1
Do While i < (k * 100) + 1
'Modify Document
i = i + 1
Loop
'Close / Save Document
Loop


There must be an easier way, but this is all my twisted mind can come up
with right now!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top