Ejemplo n.º 1
0
        public void btnConvertToPlacementSlip_Click(IRibbonControl control)
        {
            var docTitle = ((DocumentProperties)(Globals.ThisAddIn.Application.ActiveDocument.BuiltInDocumentProperties))[WordOM.WdBuiltInProperty.wdPropertyTitle].Value;

            if (Constants.TemplateNames.PlacementSlip.Equals(docTitle.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                MessageBox.Show(@"Document has already been converted into a Placement Slip", "Document is a Placement Slip", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ribbon.Invalidate();
                return;
            }

            var doc = new OfficeDocument(Globals.ThisAddIn.Application.ActiveDocument);

            WordOM.Document d = Globals.ThisAddIn.Application.ActiveDocument;
            doc.PopulateControl(Constants.WordContentControls.DocumentTitle, Constants.TemplateNames.PlacementSlip);
            doc.MoveCursorToStartOfControl(Constants.WordContentControls.Instructions);
            doc.DeleteControl(Constants.WordContentControls.Instructions);
            doc.DeleteCharacter(1);
            doc.InsertFile(Settings.Default.PlacementSlipConditionsFragement);

            ((DocumentProperties)(Globals.ThisAddIn.Application.ActiveDocument.BuiltInDocumentProperties))[WordOM.WdBuiltInProperty.wdPropertyTitle].Value = Constants.TemplateNames.PlacementSlip;
            doc.UpdateOrCreatePropertyValue(Constants.WordDocumentProperties.BuiltInTitle, Constants.TemplateNames.PlacementSlip);
            ribbon.Invalidate();

            var s = doc.GetBookmarkStartRange("QuotationDetailsStart");
            var e = doc.GetBookmarkEndRange("QuotationDetailsEnd");

            doc.DeleteRange(s, e);
            if (doc.MoveCursorToStartOfBookmark("QuotationDetailsEnd"))
            {
                doc.DeletePage();
                doc.DeleteCharacter(1);
            }
        }
Ejemplo n.º 2
0
        public void btnConvertToPlacementSlip_Click(IRibbonControl control)
        {
            var doc = new OfficeDocument(Globals.ThisAddIn.Application.ActiveDocument);

            WordOM.Document d = Globals.ThisAddIn.Application.ActiveDocument;
            doc.PopulateControl(Constants.WordContentControls.DocumentTitle, "Placement Slip");
            doc.MoveCursorToStartOfControl(Constants.WordContentControls.Instructions);
            doc.DeleteControl(Constants.WordContentControls.Instructions);
            doc.InsertFile(Settings.Default.PlacementSlipConditionsFragement);
        }