Sometimes (rarely), this will throw an error saying the object was disconnected (c#). What this means is that the original coursetemplate (not the datamerged new document) was actually in the last item position. So when I called courseTemplate.Close and the next line tried to get the last item...it got the closed document. I'm not sure why the data merged new document isn't in last place in the queue since it was the last opened document.
I could do this by name but I don't know the name of the new data merged document? is there a better way to do this?