Using Excel to start a merge session in Word

L

luthor

I want to start the merge function in Word form Excel
In Excel VBA, I use the following statements

Public Sub CommandButton1_Click()
Dim wd As Object
Dim pad, naam As String
pad = Worksheets("Basisgegevens").Range("N7").Value
naam = "boekhouding lvpc.xls"
'start Microsoft Word sessie
Set wd = CreateObject("word.application")
'Maak document zichtbaar
wd.Visible = True
'Activeer MS Word
AppActivate wd.Name
With wd
'Open geselecteerd document in Microsoft Word
.Documents.Open (pad & "\" & ListBox1.Value)
.Application.Run MacroName:="start"
End With
Set wd = Nothing
Unload Me
End Sub

I start the Word macro "start" that is going to merge ( .Application.Run
MacroName:="start") That goes wrong because the Excel session is also active
(OLE object error) and that's where the merge data is for Word (I think
that's the problem)
I'm looking for the statements in Excel VBA to merge in Word.
Who knows the solution?? (excuse me for my poor english)
Lex
 

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