I've created an excel workbook that contain two word letter and created a VBA script that automatically mail-merge said letter using data inside the workbook itself.
However when i open the letters using "OLEObject.Activate" I encounter two problems :
I've tried two methods to open the document :
Dim WDApp As Word.Application
Dim WDDoc As Word.Document
WDObject.Activate
Set WDApp = GetObject(, "Word.Application")
WDAPP.Visible = True
WDApp.DisplayAlerts = wdAlertsNone
Set WDDoc = WDApp.ActiveDocument
and :
Dim WDApp,WDOpen As Word.Application
Dim WDDoc As Word.Document
'for some reason if I try to create the application directly with WDApp it then won't be able to recognize the active document so I have to open word using a proxy
Set WDOpen = CreateObject("Word.Application")
WDOpen.Visible = True
WDOpen.DisplayAlerts = wdAlertsNone
Set WDApp = GetObject(, "Word.Application")
WDObject.Activate
Set WDDoc = WDApp.ActiveDocument
The simple answer is to not embed mailmerge main documents in your workbook. Save them outside Excel as ordinary documents before embedding them. This also means your VBA code will need to include the relevant SQL query code.