Here's the code for excel:
Code:
Sub Open_Word_Doc()
Dim WRD As Object
On Error Resume Next
Set WRD = GetObject(, "Word.Application")
If Err.Number Then
Err.Clear
Set WRD = CreateObject("Word.Application")
End If
WRD.Visible = True
WRD.Application.WindowState = wdWindowStateMaximize
WRD.Application.ScreenUpdating = True
WRD.Activate
WRD.Documents.Add Template:= _
"[Path to .dot file]", _
NewTemplate:=False
WRD.Selection.WholeStory
WRD.Selection.Fields.Update
WRD.Selection.HomeKey Unit:=wdStory
WRD.Application.ScreenUpdating = True
Set WRD = Nothing
End Sub
In my Word Template, I have this in the field code:
Code:
{Set "Width" "{DDE Excel "[Path to .xls file]" [Cell Name] \t \* mergeformat}"}
I also have this VBA code in Word:
Code:
Sub AutoNew()
Create_Reset_Variables
CallUF
End Sub
Code:
Sub CallUF()
Dim oFrm As WrdFrm
Set oFrm = New WrdFrm
With oFrm
.Show
End With
Unload oFrm
Set oFrm = Nothing
lbl_Exit:
Exit Sub
End Sub