Good point tiler, but since CEB0827 is closing the document immediately after attaching, he can avoid that problem.
You can try to do a back-end save after attaching, instead of the front end:
Call doc.Save( True, False, True )
instead of
Call uidoc.Save
And to save all changes user has made to document before clicking your attach button, you can call uidoc.save at the top of your code.
And change this part of your code:
If uidoc.Editmode = False Then
Set uidoc = ws.EditDocument( True )
End If
like this:
If uidoc.Editmode = False Then
uidoc.Editmode = True
End If
The workspace method, without NotesDocument argument, is intended to be used in views to open currently selected document.