示例#1
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");
        }
示例#2
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();
        }