Open Word Template, and have THAT file's Userform open
Hi there,
I have a main excel document that gathers data, it has a command button that opens a Word Letter template. That word document has a userform that "should" open when that word template opens. Is there a way I can open the word document AND it's userform when that word document opens?
This is the code in my excel file that open's the word template
Code:
Private Sub CommandButton11_Click()
Set appWD = CreateObject("Word.Application")
appWD.Visible = True
appWD.Documents.Open Filename:="C:\Users\Documents\Custom Office Templates\Letter 0219.dotm"
End Sub
Here is the code in Word template that opens the Userform when the document is open
Code:
Option Explicit
Dim oFrm As Userform1
Sub AutoNew()
Set oFrm = New Userform1
With oFrm
.Show
If .Tag = "CREATE DOC" Then
FillDoc
Else
ActiveDocument.Close wdDoNotSaveChanges
End If
End With
lbl_Exit:
Exit Sub
End Sub