The issue here relates to how you are converting the document (which is not shown in your example) and the reason you cannot kill the file is that it is held open by the lock file. If you look at the folder with the hidden files diplayed at the point of crashing you will see lock files for both the DOT file and the new DOTM/X file.
If you use a method similar to that shown below, the problem does not occur:
Code:
Sub Macro1()
Dim strTempName As String
Dim oDoc As Document
Dim oNewDoc As Document
Dim strNewName As String
Set oDoc = ActiveDocument
strTempName = oDoc.FullName
If Right(LCase(oDoc.Name), 3) = "dot" Then
If oDoc.HasVBProject Then
strNewName = oDoc.FullName & "m"
oDoc.SaveAs2 _
FileName:=strNewName, _
FileFormat:=wdFormatXMLTemplateMacroEnabled, _
CompatibilityMode:=Val(Application.Version)
Else
strNewName = oDoc.FullName & "x"
oDoc.SaveAs2 _
FileName:=strNewName, _
FileFormat:=wdFormatXMLTemplate, _
CompatibilityMode:=Val(Application.Version)
End If
End If
oDoc.Close 0
DoEvents
Kill strTempName
Set oDoc = Documents.Open(strNewName)
End Sub