{"id":9680,"date":"2015-06-22T19:07:30","date_gmt":"2015-06-23T02:07:30","guid":{"rendered":"https:\/\/blogs.plm.automation.siemens.com\/t5\/Solid-Edge-Blog\/Closing-Documents\/ba-p\/304483"},"modified":"2026-03-26T07:20:08","modified_gmt":"2026-03-26T11:20:08","slug":"closing-documents","status":"publish","type":"post","link":"https:\/\/blogs.sw.siemens.com\/solidedge\/closing-documents\/","title":{"rendered":"Closing Documents"},"content":{"rendered":"<p><P>Prior to Solid Edge ST8 being released, one of the developers emailed me to give me a heads up on a new API to handle closing documents. The problem has always been that in order to close a document, you had to call the Close() method of that object. The problem was that Solid Edge couldn&#8217;t fully close the document because we were still holding a reference to it. In ST8, we have a new option available.<\/P><\/p>\n<p><P>If you download the lastest <a href=\"https:\/\/github.com\/SolidEdgeCommunity\/Samples\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Samples for Solid Edge on GitHub<\/A>, you&#8217;ll notice a new <a href=\"https:\/\/github.com\/SolidEdgeCommunity\/Samples\/tree\/master\/General\/OpenClose\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">OpenClose project<\/A>. I wrote this project to demonstrate our options for closing documents. Rather than copypasting the entire code in this post, I&#8217;ll highlight the important part. The code below is C# but the VB version is available on GitHub.<\/P><\/p>\n<p><P>The main point to notice is that starting with ST8, the Documents collection has a new <a href=\"https:\/\/docs.plm.automation.siemens.com\/docs\/se\/108\/api\/SolidEdgeFramework~Documents~CloseDocument.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">CloseDocument()<\/A>&nbsp;method. This method allows you to fully release your reference to the document prior to closing it. Something we have not had the ability to do prior to ST8.<\/P><\/p>\n<p><PRE>\/\/ Prior to ST8, we needed a reference to a document to close it.<br \/>\n\/\/ That meant that SE can&#8217;t fully close the document because we&#8217;re holding a reference.<br \/>\nif (solidEdgeVesion.Major &lt; 108)<br \/>\n{<br \/>\n\t\/\/ Close the document.<br \/>\n\tdocument.Close();<\/p>\n<p>\t\/\/ Release our reference to the document.<br \/>\n\tMarshal.FinalReleaseComObject(document);<br \/>\n\tdocument = null;<\/p>\n<p>\t\/\/ Give SE a chance to do post processing (finish closing the document).<br \/>\n\tapplication.DoIdle();<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n\t\/\/ Release our reference to the document.<br \/>\n\tMarshal.FinalReleaseComObject(document);<br \/>\n\tdocument = null;<\/p>\n<p>\t\/\/ Starting with ST8, the Documents collection has a CloseDocument() method.<br \/>\n\tdocuments.CloseDocument(file.FullName, false, Missing.Value, Missing.Value, true);<br \/>\n}<\/PRE><\/p>\n<p><P>The definition of the <a href=\"https:\/\/docs.plm.automation.siemens.com\/docs\/se\/108\/api\/SolidEdgeFramework~Documents~CloseDocument.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Documents.CloseDocument()<\/A>&nbsp;method look like:<\/P><\/p>\n<p><PRE>void CloseDocument(String Filename, [Object SaveChanges], [Object SaveAsFileName], [Object RouteWorkbook], [Object DoIdle])<br \/>\n   Member of SolidEdgeFramework.Documents<\/PRE><br \/>\n<P>You will want to pass <STRONG>true<\/STRONG> to the DoIdle argument. That will prevent you from having to call application.DoIdle() manually.<\/P><\/p>\n<p><P>Be sure and check out the <a href=\"https:\/\/docs.plm.automation.siemens.com\/docs\/se\/108\/api\/Solid%20Edge%20ST8%20-%20What&#039;s%20New.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Solid Edge ST8 &#8211; What&#8217;s New<\/A>&nbsp;SDK topic. I always enjoy browsing the <a href=\"https:\/\/docs.plm.automation.siemens.com\/docs\/se\/108\/api\/WhatsNew.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">What&#8217;s New pages<\/A>&nbsp;for each version to see what goodies the development team gave us.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Prior to Solid Edge ST8 being released, one of the developers emailed me to give me a heads up on a new API to handle closing documents. The problem has always been that in order to close a document,&#8230;<\/p>\n","protected":false},"author":61367,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spanish_translation":"","french_translation":"","german_translation":"","italian_translation":"","polish_translation":"","japanese_translation":"","chinese_translation":"","footnotes":""},"categories":[1],"tags":[],"industry":[],"product":[],"coauthors":[],"class_list":["post-9680","post","type-post","status-publish","format-standard","hentry","category-news"],"_links":{"self":[{"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts\/9680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/users\/61367"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/comments?post=9680"}],"version-history":[{"count":1,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts\/9680\/revisions"}],"predecessor-version":[{"id":9681,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts\/9680\/revisions\/9681"}],"wp:attachment":[{"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/media?parent=9680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/categories?post=9680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/tags?post=9680"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/industry?post=9680"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/product?post=9680"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/coauthors?post=9680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}