May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.
'Macro in standard module: Public Sub CreateLetter() Dim doc As Word.Document Set doc = Application.Documents.Add(strWorkgroup & "Letter.dot") ' "Do stuff" with the resulting document: Call MsgBox(doc.Name) '--> RTE: Object variable or with block variable not Set ' and stepping through the code, I can see that ' the doc variable is indeed Nothing End Sub 'Event in Letter.dot: Private Sub Document_New() Dim f As frmLetter Set f = New frmLetter With f Set .CurrentDocument = ActiveDocument .Show 'After cmdOK_Click, frmLetter processes its CurrentDocument correctly End With Set f = Nothing End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.