コード例 #1
0
        private void DoNonFastSave(Document wordDocument)
        {
            if (null == wordDocument)
                return;

            if (null == m_hostApplication)
                return;

            Options options = m_hostApplication.Options;
            bool allowFastSaves = false;
            IgnoreCOMException(() => allowFastSaves = options.AllowFastSave);
            
            try
            {
                if (allowFastSaves)
                    IgnoreCOMException(() => options.AllowFastSave = false);

                wordDocument.Saved = false;
                wordDocument.UndoClear();

                SaveDocumentWithoutTrackedChangesWarning(wordDocument);
            }
            catch (COMException e)
            {
                if (FAILED_TO_OPEN_TEMPLATE != e.ErrorCode)
                    throw e;
            }
            finally
            {
                if (null != options)
                {
                    IgnoreCOMException(() => options.AllowFastSave = allowFastSaves);
                    Marshal.ReleaseComObject(options);
                }
            }
        }