Hi Helmut,
Since the main excel workbook from which Macro is executed open a word
mailmerge that is linked to the main document, it ask to close the excel
workbook to be able to set DDE connexion. If I am able to set DDE with
activeworkbook without closing it, it will work good. Do you know how ?
I have pasted here some code I tried:
Sub Execution_MailMerge_From_Excel()
On Error Resume Next
Set WdApp = GetObject("", "Word.Application")
If WdApp Is Nothing Then
Set WdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
Dim WbName as string
WbName = ActiveWorkbook.Name
Set oWordDoc = oWord.Open("C:\mailmerge.doc") 'This ask to close excel..??
Maybe, can I set condition to say: I don't want to open the excel source file
as you can click when you open only "mailmerge.doc" ?
ActiveDocument.MailMerge.OpenDataSource Name:= _
WbName, ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto, _
Connection:="merge", SQLStatement:="", SQLStatement1:="", SubType:= _
wdMergeSubTypeOther
oWord.macro1 'will execute the first Macro (In excel, I have to put the
Macro in ThisWorkbook to work: is there the same thing in word ?)
End Sub()