I have created a vba macro to streamline a process at work. The Macro works, but once it is done if I try to open another .docm file (in the same word session) it crashes. I believe it has something to do with my code in the "Else" section since it will open the file fine in the "If" section, but I can not figure it out.
Below is my code. I'm hoping one of you can see what is causing this.
Code:
Sub Save()
'Check if File exists
If Dir("\\cssshare01.nwie.net\itsd\Specialists\Chat Review\" & ActiveDocument.FormFields("Manager").Result & "\" & ActiveDocument.FormFields("Date").Result & ".docm") = "" Then
ActiveDocument.SaveAs "\\cssshare01.nwie.net\itsd\Specialists\Chat Review\" & ActiveDocument.FormFields("Manager").Result & "\" & ActiveDocument.FormFields("Date").Result & ".docm"
Documents.Open ("\\cssshare01.nwie.net\itsd\Specialists\Chat Review\Monthly Chat Review Template.docm")
Documents(2).Activate
ActiveDocument.Close
Else
ActiveDocument.Unprotect 'Unprotect Template
Selection.WholeStory 'Select all in template
Selection.Copy 'Copy all in template
'Open existing file
Documents.Open ("\\cssshare01.nwie.net\itsd\Specialists\Chat Review\" & ActiveDocument.FormFields("Manager").Result & "\" & ActiveDocument.FormFields("Date").Result & ".docm")
'Unprotect Existing
If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then ActiveDocument.Unprotect
Selection.EndKey Unit:=wdStory 'Move to end of existing
Selection.InsertBreak Type:=wdPageBreak 'Insert page break in existing
Selection.Paste 'Paste to existing
ActiveDocument.Save 'Save Existing
Documents(2).Activate 'Activate Template
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges 'Close Template
ActiveDocument.Close 'Close Existing
Documents.Open ("\\cssshare01.nwie.net\itsd\Specialists\Chat Review\Monthly Chat Review Template.docm") 'Open Template
End If
End Sub