Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            Application.DoEvents();
            int DocPageNumber = DS.GetPageNumber(Doc);

            settings.trackChange(Doc, false);
            string[] vars = new string[9];
            vars[1] = addVar("last_page_rivision", this.page_rev);
            vars[2] = addVar("last_date_rivision", this.date_rev);
            vars[3] = addVar("last_issue", this.issueText);
            vars[4] = addVar("last_effective_date", this.effectiveText);
            vars[5] = addVar("last_text1_value", this.text1_text);
            vars[6] = addVar("last_text2_value", this.text2_text);
            vars[7] = addVar("last_text3_value", this.text3_text);
            vars[8] = addVar("last_text4_value", this.text4_text);
            if (checkBox1.Checked)
            {
                DialogResult dialogResult = MessageBox.Show("Be aware this action will override all existing Dates and Rivisions data in all Pages. are you sure?", "Update all Doc?", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    string edoc_page_text = "";
                    for (int i = 0; i < pageView.Items.Count; i++)
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        edoc_page_text = "edocs_Page" + pageView.CheckedItems[i].SubItems[0].Text + "_page";
                        try {
                            vars[0] = Doc.Variables[edoc_page_text].Value;
                            saveChanges(vars, i);
                        }
                        catch
                        {
                            continue;
                        }
                    }
                }
            }
            else
            {
                string edoc_page_text = "";
                for (int i = 0; i < pageView.CheckedItems.Count; i++)
                {
                    Cursor.Current = Cursors.WaitCursor;
                    edoc_page_text = "edocs_Page" + pageView.CheckedItems[i].SubItems[0].Text + "_page";
                    try
                    {
                        vars[0] = Doc.Variables[edoc_page_text].Value;
                        saveChanges(vars, i);
                    }
                    catch
                    {
                        continue;
                    }
                }
                Cursor.Current = Cursors.Default;
            }
            Cursor.Current = Cursors.Default;
            pageView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            DS.UpDateFields();
        }
Пример #2
0
        public static void ProcessMonitoring(Word.Document Doc)
        {
            DocSettings DS = new DocSettings(Doc);

            for (int i = 1; i <= DS.GetPageNumber(Doc); i++)
            {
                DS.changePageData(i);
            }
            DS.UpDateFields();
        }
Пример #3
0
        public void insertText(string filedName, Word.Range rng)
        {
            if (!isActiveAddin())
            {
                return;
            }
            Doc = Globals.ThisAddIn.Application.ActiveDocument;
            if (!settings.check_if_edoc(Doc))
            {
                MessageBox.Show("eDoc Only");
                return;
            }
            settings.trackChange(Doc, false);
            DocSettings DS = new DocSettings(Doc, "WTF");

            DS.InesrtRevDatatoAllHeadingCells(filedName, rng);
            DS.UpDateFields();
        }
Пример #4
0
        public void insertSectionPageTemplateText(Office.IRibbonControl control)
        {
            if (!isActiveAddin())
            {
                return;
            }
            Doc = Globals.ThisAddIn.Application.ActiveDocument;

            /**
             * string pageCode = "X-P1";
             * try{
             *  pageCode = Doc.Variables["pageTemplate"].Value;
             * }
             * catch{}
             * insertText(pageCode, Doc.Application.Selection.Range);
             *          BuildFields( "\"edocs_Page_" + data + "\"", data);
             **/

            Word.Range range      = Doc.Application.Selection.Range;
            int        rangeStart = range.Start;

            range.Text = " ";
            range.End  = range.Start;
            range.Fields.Add(range, Word.WdFieldType.wdFieldDocVariable, "\"edocs_Page_\"", false);


            range.SetRange(rangeStart + 26, rangeStart + 26);
            range.Fields.Add(range, Word.WdFieldType.wdFieldDocVariable, "\"pageTemplate\"", false);

            range.SetRange(rangeStart + 25, rangeStart + 25);
            range.Fields.Add(range, Word.WdFieldType.wdFieldDocVariable, "\"edocs_Page_page\"", false);


            range.Start = range.Start + 25;
            range.Fields.Add(range, Word.WdFieldType.wdFieldEmpty, @"PAGE  \* ARABIC", false);

            DocSettings DS = new DocSettings(Doc, "WTF");

            DS.UpDateFields();
        }
Пример #5
0
        public static void process_doc(Word.Document Doc, string type)
        {
            DocSettings DS = new DocSettings(Doc);

            DS.IsAlert = true;
            int DocPageNumber = DS.GetPageNumber(Doc);

            System.Diagnostics.Debug.WriteLine("DocPageNumber process doc - " + DocPageNumber);
            if (DS.PageNumberFromHeaders(DocPageNumber, type))
            {
                if (settings.monitorDoc)
                {
                    DS.processMonitoring();
                    settings.monitorDoc = false;
                }
            }
            DS.UpDateFields();;
            trackChange(Doc, false);
            Doc.Application.ActiveWindow.VerticalPercentScrolled = 0;
            Globals.ThisAddIn.m_Ribbon.ribbon.InvalidateControl("toggleButton_ribbon");
            Globals.ThisAddIn.m_Ribbon.ribbon.InvalidateControl("rev_cbo");
            Globals.ThisAddIn.m_Ribbon.ribbon.InvalidateControl("date_cbo");
        }
Пример #6
0
        public static void init_ListOfE_New(Word.Document RealDoc)
        {
            // JUST FOR ADD PAGES TO
            //BuildTable_ListOfEffctive_BigData(RealDoc, RealDoc.Tables[2]);
            // return;
            //END OF BIG DATA
            Object      SelectionNext;
            DocSettings DS = new DocSettings(RealDoc);

            SelectionNext = RealDoc.Application.Selection.End;
            Word.Range rangeForToCopy = RealDoc.Range(ref SelectionNext, ref SelectionNext);
            int        pageSize       = 4;

            if (rangeForToCopy.PageSetup.PaperSize == Word.WdPaperSize.wdPaperA5)
            {
                pageSize = 5;
            }
            int    currentPageNum      = Convert.ToInt32(RealDoc.Application.Selection.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdActiveEndPageNumber));
            object currentPageNumToRef = currentPageNum;

            Word.Document DocOfE = null;
            try
            {
                DocOfE = Globals.ThisAddIn.Application.Documents.Add(LOEPPath(pageSize));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something Went Wrong - " + ex.Message);
                OpenFileDialog openFile = new OpenFileDialog();
                openFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
                openFile.Title            = "Select Word Template";
                openFile.FileName         = "";
                openFile.Filter           = "Word Documents (*.doc;*.docx)|*.doc;*.docx";
                if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    DocOfE = Globals.ThisAddIn.Application.Documents.Add(openFile.FileName);
                }
                else
                {
                    settings.alert.Close();
                }
            }
            Cursor.Current = Cursors.WaitCursor;
            DocOfE.Tables[1].Range.Copy();
            rangeForToCopy.PasteAndFormat(Word.WdRecoveryType.wdFormatOriginalFormatting);
            try
            {
                int DocPageNumber = DS.GetPageNumber(RealDoc);
                RealDoc.Activate();
                int FirstHeaderPage = 0;
                int pageToDo        = BuildTable_ListOfEffctivePage(DS, rangeForToCopy.Tables[1], DocPageNumber, FirstHeaderPage);
                copyCellsToTable(rangeForToCopy.Tables[1], DocOfE.Tables[2], (DocPageNumber + pageToDo - FirstHeaderPage), FirstHeaderPage);
                DocOfE.Close(ref saveOption, ref originalFormat, ref routeDocument);
                if (pageToDo > 0)
                {
                    try
                    {
                        string PageString = RealDoc.Variables["edocs_Page" + currentPageNum + "_page"].Value;
                        string PageRev    = RealDoc.Variables["edocs_Page" + PageString + "_rev"].Value;
                        string PageDate   = RealDoc.Variables["edocs_Page" + PageString + "_date"].Value;
                        for (int i = currentPageNum + 1; i <= currentPageNum + pageToDo; i++)
                        {
                            string PageString2 = RealDoc.Variables["edocs_Page" + i + "_page"].Value;
                            RealDoc.Variables["edocs_Page" + PageString2 + "_rev"].Value  = PageRev;
                            RealDoc.Variables["edocs_Page" + PageString2 + "_date"].Value = PageDate;
                        }
                    }
                    catch { }
                }
                try { string test1 = RealDoc.Variables["processType"].Value; }
                catch { RealDoc.Variables.Add("processType", "styles"); }
                if (pageToDo == -1 || !DS.PageNumberFromHeaders(DocPageNumber + pageToDo, RealDoc.Variables["processType"].Value))
                {
                    RealDoc.Application.ScreenUpdating = true;
                }
                RealDoc.Application.Selection.GoTo(ref what, ref which, ref currentPageNumToRef, ref missing);
                trackChange(RealDoc, true);
            }
            catch (Exception ex)
            {
                trackChange(RealDoc, true);
                RealDoc.Application.ScreenUpdating = true;
                MessageBox.Show("Something Went Wrong - " + ex.Message);
                settings.alert.Close();
            }
            Cursor.Current = Cursors.Default;
            rangeForToCopy.Tables[1].Range.Fields.Locked = 0;
            rangeForToCopy.Tables[1].Range.Fields.Update();
            DS.UpDateFields();
        }