Exemplo n.º 1
0
        public void WordMarks(string filename, string currDir, string mark1, string mark2, string mark3, string mark4, string mark5, string group, string parent)
        {
            db  = new UseDataBase();
            app = new Word.Application();
            doc = app.Documents.Add(currDir);
            doc.Activate();
            wBookmarks = doc.Bookmarks;
            dt         = new DataTable();
            dt         = db.SQLQuery("SELECT Teachers.FIO FROM Teachers INNER JOIN Groups ON Groups.idTeacher = Teachers.idTeacher where Groups.Name = '" + mark5 + "'");
            string teacherFio = dt.Rows[0][0].ToString();

            data = new string[5] {
                mark1, mark2, mark3, mark4, teacherFio
            };
            foreach (Microsoft.Office.Interop.Word.Bookmark mark in wBookmarks)
            {
                wRange      = mark.Range;
                wRange.Text = data[i];
                i++;
            }
            i         = 0;
            filename += "_" + group + "_" + parent;
            doc.SaveAs(FileName: (Environment.CurrentDirectory + @"\report\" + filename));
            string path = Environment.CurrentDirectory + @"\report\" + filename + ".docx";

            doc.Close();
            doc = null;
            app.Quit();

            dt = db.SQLQuery("SELECT DISTINCT Parents.Email FROM Parents, Groups INNER JOIN ParentsSudents ON ParentsSudents.idParent = Parents.idParent INNER JOIN Students ON Students.idGroup = Groups.idGroup AND ParentsSudents.idStudent = Students.idStudent WHERE Groups.Name = '" + group + "' and Parents.FIO = '" + parent + "'");
            string ParentEmail = dt.Rows[0][0].ToString();

            mail = new SendAnEmail();
            mail.MultiMessage(ParentEmail, "Уведомление от РКРИПТ", "", @path);
        }
Exemplo n.º 2
0
 //Ограничение. Замена закладки происходит только в случае оригинальности имени закладки, то есть
 //ИМЕНА закладок не должны повторяться или будет произведена замена по образцу первой закладки
 private static void Booking(Word.Range temppath, List <String> bookMarks, List <String> replaceBooksmarks)
 {
     try
     {
         Word.Bookmarks wBookmarks = doc.Bookmarks;
         int            i          = 0;
         foreach (Word.Bookmark mark in wBookmarks)
         {
             Console.WriteLine("Закладка номер " + i.ToString());
             temppath = mark.Range;
             if (bookMarks.Contains(mark.Name))
             {
                 Console.WriteLine("Название закладки: " + mark.Name);
                 temppath.Text = replaceBooksmarks[bookMarks.IndexOf(mark.Name)];
                 Console.WriteLine("Замена закладки: " + temppath.Text);
             }
             i++;
         }
     }
     catch (Exception exp)
     {
         Console.WriteLine("Ошибка чтения закладок: " + exp.Message);
         Close();
         Console.ReadKey();
     }
 }
        public static void InWord(Dictionary <string, string> dict, string path)
        {
            if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + path))
            {
                MessageBox.Show($"Файл шаблона ({AppDomain.CurrentDomain.BaseDirectory + path}) не найден");
            }
            try
            {
                Word.Application app    = new Word.Application();
                string           source = AppDomain.CurrentDomain.BaseDirectory + path;
                Word.Document    doc    = app.Documents.Add(source);
                doc.Activate();
                Word.Bookmarks bookmarks = doc.Bookmarks;

                foreach (var b in dict)
                {
                    bookmarks[b.Key].Range.Text = b.Value;
                }

                app.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Произошла ошибка");
            }
        }
Exemplo n.º 4
0
        public static void InWord(IEnumerable <Tuple <string, string> > res, string relativeSource)
        {
            try
            {
                Word.Application app    = new Word.Application();
                string           source = AppDomain.CurrentDomain.BaseDirectory + relativeSource;
                Word.Document    doc    = app.Documents.Add(source);
                doc.Activate();
                Word.Bookmarks bookmarks = doc.Bookmarks;

                StringBuilder result = new StringBuilder();

                foreach (var b in res)
                {
                    result.AppendLine(b.Item1);
                    result.AppendLine(b.Item2);
                }

                bookmarks["Results"].Range.Text    = result.ToString();
                bookmarks["Name"].Range.Text       = StaticParameters.User.Name;
                bookmarks["SecondName"].Range.Text = StaticParameters.User.SecondName;

                app.PrintOut(Range: Word.WdPrintOutRange.wdPrintAllDocument);
            }
            catch
            {
                MessageBox.Show("Произошла ошибка с печатью документа");
            }
        }
Exemplo n.º 5
0
        private void CreateWordDocument()
        {
            _Document oDoc = null;

            try
            {
                Word._Application oWord  = new Word.Application();
                string            source = @"C:\Users\temch\Desktop\Шаблон.dotx";
                oDoc = oWord.Documents.Add(source);
                Word.Bookmarks wBookmarks = oDoc.Bookmarks;
                Word.Range     wRange;
                string[]       arr = { "27", "Tema", "Shevchenko" };
                int            i   = 0;
                foreach (Word.Bookmark mark in wBookmarks)
                {
                    wRange      = mark.Range;
                    wRange.Text = arr[i];
                    i++;
                }
                string pathToSaveObj = @"C:\Users\temch\Desktop\Контракт.docx";
                oDoc.SaveAs2(pathToSaveObj);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                oDoc.Close();
                oDoc = null;
            }
        }
Exemplo n.º 6
0
        public void ExportDotx(string dir, string text)
        {
            object template = dir + "\\exampleDotx.dotx";

            Word._Application word = new Word.Application()
            {
                Visible = true
            };
            Word._Document doc = word.Documents.Add(template);

            // Поиск закладки Name и вставка введенного текста
            String nameMark = "Name";

            Word.Bookmarks bookmarks = doc.Bookmarks;

            foreach (Word.Bookmark mark  in bookmarks)
            {
                if (mark.Name == nameMark)
                {
                    mark.Range.Text = text;
                }
            }

            doc.SaveAs(dir + "\\newTemplate.docx");
            doc.Close();
            word.Quit();
        }
Exemplo n.º 7
0
        //Open document on new object
        public DocBuffer()
        {
            //Clear out unused buffer bookmarks
            Word.Bookmarks bookmarks = Globals.ThisAddIn.Application.ActiveDocument.Bookmarks;
            bookmarks.ShowHidden = true;

            foreach (Word.Bookmark mark in bookmarks)
            {
                if (mark.Name.Contains("_buf"))
                {
                    mark.Delete();
                }
            }

            //Remove trail of undo's for clearing out the bookmarks
            Globals.ThisAddIn.Application.ActiveDocument.UndoClear();

            //Set up template
            template    = Globals.ThisAddIn.Application.NormalTemplate;
            templateObj = template;

            //Open Blank document, then attach styles *and update
            HiddenDoc = Globals.ThisAddIn.Application.Documents.Add(ref missing, ref missing, ref missing, ref FalseObj);
            HiddenDoc.set_AttachedTemplate(ref templateObj);
            HiddenDoc.UpdateStyles();

            //Tell hidden document it has been saved to remove rare prompt to save document
            HiddenDoc.Saved = true;

            //Make primary document active
            Globals.ThisAddIn.Application.ActiveDocument.Activate();
        }
Exemplo n.º 8
0
        public bool SetWordBookmarks(Word.Application objWord, Word.Bookmarks objBookmarks, string bookMarkName, string bookMarkValue)
        {
            try
            {
                Word.Bookmark objBookmark = null;
                Word.Range    objRange    = null;
                object        objName;

                // Name of Bookmark - Object in the Word Template
                objName = bookMarkName;

                // get the Bookmark
                objBookmark = objBookmarks.get_Item(ref objName);
                objRange    = objBookmark.Range;

                // set new value of Bookmark and
                // write new Bookmark back to Word.Document
                objRange.Text = bookMarkValue;

                return(true);
            }
            catch (Exception ex)
            {
                Console.Beep();
                Console.Beep();
                Message = String.Format("EXCEPTION: {0}", ex.ToString());
                return(false);
            }
        }
Exemplo n.º 9
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            Data();
            Word.Document doc = null;
            try
            {
                Word.Application app = new Word.Application();

                //    string source = @"D:\\Doctor.docx";
                doc = app.Documents.Open(path + "\\Doctor.docx");
                doc.Activate();
                Word.Bookmarks wBookmarks = doc.Bookmarks;
                Word.Range     wRange;
                int            i = 0;

                foreach (Word.Bookmark mark in wBookmarks)
                {
                    wRange      = mark.Range;
                    wRange.Text = data[i];
                    i++;
                }
                Object fileName                = @"D:\\" + Patient.Text + ".doc";
                Object fileFormat              = Word.WdSaveFormat.wdFormatDocument;
                Object lockComments            = false;
                Object password                = "";
                Object addToRecentFiles        = false;
                Object writePassword           = "";
                Object readOnlyRecommended     = false;
                Object embedTrueTypeFonts      = false;
                Object saveNativePictureFormat = false;
                Object saveFormsData           = false;
                Object saveAsAOCELetter        = Type.Missing;
                Object encoding                = Type.Missing;
                Object insertLineBreaks        = Type.Missing;
                Object allowSubstitutions      = Type.Missing;
                Object lineEnding              = Type.Missing;
                Object addBiDiMarks            = Type.Missing;
                doc.SaveAs(ref fileName,
                           ref fileFormat, ref lockComments,
                           ref password, ref addToRecentFiles, ref writePassword,
                           ref readOnlyRecommended, ref embedTrueTypeFonts,
                           ref saveNativePictureFormat, ref saveFormsData,
                           ref saveAsAOCELetter, ref encoding, ref insertLineBreaks,
                           ref allowSubstitutions, ref lineEnding, ref addBiDiMarks);
                doc.Close();
                doc = null;
            }
            catch (Exception ex)
            {
                doc.Close();
                doc = null;
                Console.WriteLine("Во время выполнения произошла ошибка!");
                Console.ReadLine();
            }
        }
Exemplo n.º 10
0
        private void button1_Click(object sender, RibbonControlEventArgs e)
        {
            Document vstoDocument = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveDocument);

            Word.Document oDoc = Globals.ThisAddIn.Application.ActiveDocument;

            string extName = DateTime.Now.Ticks.ToString();

            extName = extName.Substring(extName.Length - 3);

            string name = "CTButton" + extName;

            if (Globals.Ribbons.RibbonAddin.button1 != null)
            {
                Word.Selection oSelection = Globals.ThisAddIn.Application.Selection;
                if (oSelection != null && oSelection.Range != null)
                {
                    try
                    {
                        // addButton(vstoDocument,oSelection.Range, name);

                        Word.Range range = oSelection.Range;
                        object     obj   = (object)range;
                        oDoc.Bookmarks.Add(name, ref obj);
                        // Globals.ThisAddIn.Application.ActiveDocument.Save();
                        MessageBox.Show("Added Button:" + vstoDocument.Bookmarks.Count);

                        //var ctl = oDoc.ContentControls.Add(Word.WdContentControlType.wdContentControlText, ref obj);

                        addButton(vstoDocument, oSelection.Range, name);

                        Word.Bookmarks bookmarks = Globals.ThisAddIn.Application.ActiveDocument.Bookmarks;
                        foreach (Word.Bookmark bookm in bookmarks)
                        {
                            MessageBox.Show(bookm.Name);
                            if (bookm.Name.StartsWith("CTButton"))
                            {
                                //addButton(vstoDocument, bookmarks[i].Range, bookmarks[i].Name);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Fail to add Button" + ex.ToString());
                    }
                }
            }
            else
            {
                vstoDocument.Controls.Remove(name);
            }
            vstoDocument.BeforePrint += new System.ComponentModel.CancelEventHandler(vstoDocument_BeforePrint);
        }
Exemplo n.º 11
0
        public void GenerateWordFile()
        {
            Word._Application wApp  = new Word.Application();
            Word.Documents    wDocs = wApp.Documents;
            Word._Document    wDoc  = wDocs.Open(@"C:\Users\s.stadtler\source\repos\FST01\Sourcecode\FST.TournamentPlanner\FST.TournamentPlanner.Test\Urkunde_v1_edit.docx", ReadOnly: false);
            wDoc.Activate();

            Word.Bookmarks wBookmarks = wDoc.Bookmarks;
            Word.Bookmark  wBookmark  = wBookmarks["Tuniername"];
            Word.Range     wRange     = wBookmark.Range;
            wRange.Text = "Supertunier";
        }
Exemplo n.º 12
0
        //在书签位置插入一段文字,text为文字内容
        public void InsertText(string bookmark, string text)
        {
            object oStart = bookmark;
            object range  = wordDoc.Bookmarks.get_Item(ref oStart).Range;

            Microsoft.Office.Interop.Word.Bookmarks wdBookmarks = wordDoc.Bookmarks;
            Microsoft.Office.Interop.Word.Bookmark  wdBookmark  = wdBookmarks.get_Item(ref oStart);
            Microsoft.Office.Interop.Word.Selection wdSel;
            wdBookmark.Select();
            wdSel      = wordApp.Selection;
            wdSel.Text = text;
            wordDoc.Paragraphs.Last.Range.Text = "\n";
        }
Exemplo n.º 13
0
        //删除书签
        private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            BM_Word = FrmGHBZTLContents.W_Doc;
            W_Bkm   = BM_Word.Bookmarks;
            if (gridView2.SelectedRowsCount == 0)
            {
                MessageBox.Show("请选择标签");
                return;
            }
            object bookmarkid   = gridView2.GetRowCellDisplayText(this.gridView2.FocusedRowHandle, "UID").ToString();
            string bookmarkname = gridView2.GetRowCellDisplayText(this.gridView2.FocusedRowHandle, "MarkName").ToString();
            string booktype     = gridView2.GetRowCellDisplayText(this.gridView2.FocusedRowHandle, "MarkType").ToString();

            Word.Range temprange = null;
            bool       flag      = W_Bkm.Exists("test");

            if (W_Bkm.Exists(bookmarkid.ToString()))
            {
                temprange = W_Bkm.get_Item(ref bookmarkid).Range;
                temprange.Select();
            }
            if (booktype == "程序员")
            {
                MessageBox.Show("您不能删除程序员定义的标签,否则程序无法正常更新数据!");
                return;
            }
            if (MessageBox.Show("确定要删除书签" + bookmarkname + "?", "询问", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                //替换后标签就自动删除了
                if (W_Bkm.Exists(bookmarkid.ToString()))
                {
                    temprange.Text       = temprange.Text;
                    temprange.Font.Color = Word.WdColor.wdColorBlack;
                }

                LayoutBookMark data = this.gridView2.GetRow(this.gridView2.FocusedRowHandle) as LayoutBookMark;// new Ps_Table_GDP();
                try
                {
                    Common.Services.BaseService.Delete <LayoutBookMark>(data);
                    InitGrid2();
                    this.Refresh();
                    MessageBox.Show("删除成功");
                    FrmGHBZTLContents.ParentForm.SaveData_Word();
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Exemplo n.º 14
0
        public static bool Print(string fileName, XModelBase model)
        {
            Word.Application app = new Word.Application();
            Word.Document    dct = app.Documents.Open(fileName);

            Word.Bookmarks bookMarks = dct.Bookmarks;
            foreach (Word.Bookmark bookMark in bookMarks)
            {
                string bookMarkValue = GetBookMarkValue(bookMark.Name, model);
                bookMark.Range.Text = bookMarkValue;
            }
            app.Visible = true;
            return(true);
        }
Exemplo n.º 15
0
        static void InsertToWaterMark()
        {
            // Создаём объект документа
            Word.Document doc = null;
            try
            {
                // Создаём объект приложения
                Word.Application app = new Word.Application();
                // Путь до шаблона документа
                string source = @"D:\\test.docx";
                // Открываем
                doc = app.Documents.Open(source);
                doc.Activate();


                // test
                List <string> tested = new List <string>();
                tested.Reverse();

                // Добавляем информацию
                // wBookmarks содержит все закладки
                Word.Bookmarks wBookmarks = doc.Bookmarks;
                Word.Range     wRange;
                int            i    = 0;
                string[]       data = new string[4] {
                    "27", "Alex", "Gulynin", "tested"
                };
                Array.Reverse(data);

                foreach (Word.Bookmark mark in wBookmarks)
                {
                    wRange      = mark.Range;
                    wRange.Text = data[i];
                    i++;
                }

                // Закрываем документ
                doc.Close();
                doc = null;
            }
            catch (Exception ex)
            {
                // Если произошла ошибка, то
                // закрываем документ и выводим информацию
                doc.Close();
                doc = null;
                Console.WriteLine("Во время выполнения произошла ошибка!");
                Console.ReadLine();
            }
        }
Exemplo n.º 16
0
        private void metroButton5_Click(object sender, EventArgs e)
        {
            Word.Document doc = null;
            try
            {
                // Создаём объект приложения
                Word.Application app = new Word.Application();
                // Путь до шаблона документа
                string source = @"E:\\медкарта.docx";
                // Открываем
                doc = app.Documents.Add(source);
                doc.Activate();
                string gender = "мужской";
                if (Convert.ToInt32(dataGridView1.CurrentRow.Cells[4].Value) == 1)
                {
                    gender = "женский";
                }
                // Добавляем информацию
                // wBookmarks содержит все закладки
                Word.Bookmarks wBookmarks = doc.Bookmarks;
                Word.Range     wRange;
                int            i    = 0;
                string[]       data = new string[11] {
                    dataGridView1.CurrentRow.Cells[6].Value.ToString(), dataGridView1.CurrentRow.Cells[9].Value.ToString(), gender,
                    dataGridView1.CurrentRow.Cells[10].Value.ToString(), dataGridView1.CurrentRow.Cells[3].Value.ToString(), dataGridView1.CurrentRow.Cells[2].Value.ToString(),
                    dataGridView1.CurrentRow.Cells[0].Value.ToString(), dataGridView1.CurrentRow.Cells[8].Value.ToString(), dataGridView1.CurrentRow.Cells[5].Value.ToString(),
                    dataGridView1.CurrentRow.Cells[7].Value.ToString(), dataGridView1.CurrentRow.Cells[1].Value.ToString()
                };
                foreach (Word.Bookmark mark in wBookmarks)
                {
                    wRange      = mark.Range;
                    wRange.Text = data[i];
                    i++;
                }

                // Закрываем документ
                doc.Close();
                doc = null;
            }
            catch (Exception ex)
            {
                // Если произошла ошибка, то
                // закрываем документ и выводим информацию
                doc.Close();
                doc = null;
                Console.WriteLine("Во время выполнения произошла ошибка!");
                Console.ReadLine();
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Generates the winners certificates and stores them to a file
        ///
        /// The file path is returned
        /// </summary>
        /// </summary>
        /// <param name="name"></param>
        /// <param name="rank"></param>
        /// <param name="tournamentname"></param>
        /// <param name="place"></param>
        /// <param name="date"></param>
        /// <returns>Path to generated certificate</returns>
        public static XpsDocument Generate(string name, int rank, string tournamentname, string place, string date)
        {
            Word.Application wApp = new Word.Application();
            wApp.Visible = false;

            Word.Documents wDocs        = wApp.Documents;
            object         missing      = System.Reflection.Missing.Value;
            string         templatePath = AppDomain.CurrentDomain.BaseDirectory + @"WinnerCertificatesTemplate\Urkunde_v2_final.docm";

            Word.Document wDoc = wDocs.Open(templatePath,
                                            missing,
                                            ReadOnly: false,
                                            Visible: false,
                                            Revert: false);
            wApp.WindowState = WdWindowState.wdWindowStateMinimize;
            wDoc.Activate();

            Word.Bookmarks wBookmarks = wDoc.Bookmarks;
            Word.Bookmark  wBookmark  = wBookmarks["TournamentName"];
            Word.Range     wRange     = wBookmark.Range;
            wRange.Text = tournamentname;

            Word.Bookmark wBookmark2 = wBookmarks["Name"];
            Word.Range    wRange2    = wBookmark2.Range;
            wRange2.Text = name;

            Word.Bookmark wBookmark3 = wBookmarks["Rank"];
            Word.Range    wRange3    = wBookmark3.Range;
            wRange3.Text = rank.ToString();

            Word.Bookmark wBookmark4 = wBookmarks["Place"];
            Word.Range    wRange4    = wBookmark4.Range;
            wRange4.Text = place;

            Word.Bookmark wBookmark5 = wBookmarks["Date"];
            Word.Range    wRange5    = wBookmark5.Range;
            wRange5.Text = date;

            string convertedXpsDoc = string.Concat(Path.GetTempPath(), "\\", Guid.NewGuid().ToString(), ".xps");

            wDoc.SaveAs(convertedXpsDoc, WdSaveFormat.wdFormatXPS);
            XpsDocument xpsDocument = new XpsDocument(convertedXpsDoc, FileAccess.Read);

            wDoc.Close(SaveChanges: false);
            wApp.Quit();

            return(xpsDocument);
        }
Exemplo n.º 18
0
        private void button5_Click(object sender, EventArgs e)// печть в ворд
        {
            //Создаём объект документа
            Word.Document doc = null;
            try
            {
                // Создаём объект приложения
                Word.Application app = new Word.Application();
                // Путь до шаблона документа
                string source = @"C:\Users\ken\Desktop\авториз2\Ладья Договор.doc";
                // Открываем
                doc = app.Documents.Open(source);
                doc.Activate();

                // Добавляем информацию
                // wBookmarks содержит все закладки
                Word.Bookmarks wBookmarks = doc.Bookmarks;
                Word.Range     wRange;
                int            i       = 0;
                var            DATA_DV = dateTimePicker1.Text;
                //var b = dateTimePicker2.Text;
                var FIO = comboBox1.Text;
                // var d = textBox3.Text;
                string[] data = new string[2] {
                    DATA_DV, FIO
                };                                              //формирование акта в документе
                foreach (Word.Bookmark mark in wBookmarks)
                {
                    wRange      = mark.Range;
                    wRange.Text = data[i];
                    i++;
                }
                Console.WriteLine(i.ToString());
                // Закрываем документ
                doc.Close();
                doc = null;
            }
            catch (Exception ex)
            {
                // Если произошла ошибка, то
                // закрываем документ и выводим информацию
                doc.Close();
                doc = null;
                Console.WriteLine("Во время выполнения произошла ошибка!");
                Console.ReadLine();
            }
        }
Exemplo n.º 19
0
        private void RibbonAddin_Load(object sender, RibbonUIEventArgs e)
        {
            Document vstoDocument = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveDocument);

            Word.Bookmarks bookmarks = Globals.ThisAddIn.Application.ActiveDocument.Bookmarks;
            MessageBox.Show(bookmarks.Count.ToString());
            foreach (Word.Bookmark bookm in bookmarks)
            {
                MessageBox.Show(bookm.Name);
                if (bookm.Name.StartsWith("CTButton"))
                {
                    addButton(vstoDocument, bookm.Range, bookm.Name);
                }
            }

            object rng = Globals.ThisAddIn.Application.ActiveDocument.Paragraphs.First.Range;

            Globals.ThisAddIn.Application.ActiveDocument.Bookmarks.Add("test");
        }
Exemplo n.º 20
0
        //查找名称
        private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (barEditItem1.EditValue == null)
            {
                MessageBox.Show("请输入要查找的书签的名称");
                return;
            }
            if (gridView2.RowCount == 0)
            {
                MessageBox.Show("没有书签可查找");
                return;
            }
            string tagstr = barEditItem1.EditValue.ToString();

            for (int i = num + 1; i <= gridView2.RowCount; i++)
            {
                if (i == gridView2.RowCount)
                {
                    num = -1;
                    MessageBox.Show("已搜索到结尾");
                }
                if (gridView2.GetRowCellDisplayText(i, "MarkName").ToString().Contains(tagstr))
                {
                    gridView2.FocusedRowHandle = i;
                    this.Refresh();
                    num = i;
                    //定位该书签
                    BM_Word = FrmGHBZTLContents.W_Doc;
                    W_Bkm   = BM_Word.Bookmarks;
                    object     bookmarkid   = gridView2.GetRowCellDisplayText(this.gridView2.FocusedRowHandle, "UID").ToString();
                    string     bookmarkname = gridView2.GetRowCellDisplayText(this.gridView2.FocusedRowHandle, "MarkName").ToString();
                    Word.Range temprange    = null;
                    if (W_Bkm.Exists(bookmarkid.ToString()))
                    {
                        temprange = W_Bkm.get_Item(ref bookmarkid).Range;
                        temprange.Select();
                    }
                    break;
                }
            }
            //barEditItem1.Caption;
        }
Exemplo n.º 21
0
        /// <summary>
        /// 转换实例
        /// </summary>
        /// <param name="dataSource"></param>
        public void Instantiate(DataSource dataSource)
        {
            WriteLog("开始替换书签!");
            if (_document == null)
            {
                WriteLog("目标文档不存在,跳过!");
                return;
            }

            Microsoft.Office.Interop.Word.Bookmarks bookmarks = _document.Bookmarks;
            foreach (Microsoft.Office.Interop.Word.Bookmark item in bookmarks)
            {
                if (dataSource.IsSupported(item.Name))
                {
                    DataItem data     = dataSource[item.Name];
                    Bookmark bookmark = Bookmark.CreateBookmark(item, this, data.Type);
                    bookmark.Instantiate(data.Value);
                }
            }
        }
Exemplo n.º 22
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            Data();
            Word.Document doc = null;
            try
            {
                // Создаём объект приложения
                Word.Application app = new Word.Application();
                // Путь до шаблона документа
                string source = @"D:\\Doctor.docx";
                // Открываем
                doc = app.Documents.Open(source);
                doc.Activate();

                // Добавляем информацию
                // wBookmarks содержит все закладки
                Word.Bookmarks wBookmarks = doc.Bookmarks;
                Word.Range     wRange;
                int            i = 0;

                foreach (Word.Bookmark mark in wBookmarks)
                {
                    wRange      = mark.Range;
                    wRange.Text = data[i];
                    i++;
                }

                // Закрываем документ
                doc.Close();
                doc = null;
            }
            catch (Exception ex)
            {
                // Если произошла ошибка, то
                // закрываем документ и выводим информацию
                doc.Close();
                doc = null;
                Console.WriteLine("Во время выполнения произошла ошибка!");
                Console.ReadLine();
            }
        }
Exemplo n.º 23
0
        //private Dictionary<string, string> Bookmarks = null;

        public WordTemplate(string templatePath)
        {
            this.Type         = TemplateType.WordTemplate;
            this.TemplatePath = templatePath;

            oWord = new Application();
            oDoc  = new Document();

            object readOnly  = false;
            object isVisible = false;
            object oTemplate = TemplatePath;

            Microsoft.Office.Interop.Word.Documents oDocTmp = oWord.Documents;
            oWord.Visible = false;

            try
            {
                oDoc = oDocTmp.Open(ref oTemplate,
                                    ref _missing,
                                    ref readOnly,
                                    ref _missing,
                                    ref _missing,
                                    ref _missing,
                                    ref _missing,
                                    ref _missing,
                                    ref _missing,
                                    ref _missing,
                                    ref _missing,
                                    ref isVisible,
                                    ref _missing,
                                    ref _missing,
                                    ref _missing,
                                    ref _missing);
            }
            catch (Exception ex)
            {
                this.Dispose();
                throw new Exception("Не удалось открыть документ.\r\n" + ex.Message);
            }
            oBookmarks = oDoc.Bookmarks;
        }
Exemplo n.º 24
0
        private void RibbonAddin_Load(object sender, RibbonUIEventArgs e)
        {
            vstoDocument = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveDocument);

            Word.Bookmarks bookmarks = Globals.ThisAddIn.Application.ActiveDocument.Bookmarks;
            MessageBox.Show(bookmarks.Count.ToString());
            foreach (Word.Bookmark bookm in bookmarks)
            {
                MessageBox.Show(bookm.Name);
                if (bookm.Name.StartsWith("CTButton"))
                {
                    addButton(vstoDocument, bookm.Range, bookm.Name);
                }
            }

            object rng = Globals.ThisAddIn.Application.ActiveDocument.Paragraphs.First.Range;

            Globals.ThisAddIn.Application.ActiveDocument.Bookmarks.Add("test");
            oDoc = Globals.ThisAddIn.Application.ActiveDocument;

            Globals.ThisAddIn.Application.DocumentBeforePrint += Application_DocumentBeforePrint;
            vstoDocument.BeforePrint += new System.ComponentModel.CancelEventHandler(vstoDocument_BeforePrint);
        }
Exemplo n.º 25
0
        //定位书签
        private void barButtonItem13_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            BM_Word = FrmGHBZTLContents.W_Doc;
            W_Bkm   = BM_Word.Bookmarks;
            if (gridView2.SelectedRowsCount == 0)
            {
                MessageBox.Show("请选择标签");
                return;
            }
            object bookmarkid   = gridView2.GetRowCellDisplayText(this.gridView2.FocusedRowHandle, "UID").ToString();
            string bookmarkname = gridView2.GetRowCellDisplayText(this.gridView2.FocusedRowHandle, "MarkName").ToString();

            Word.Range temprange = null;
            if (W_Bkm.Exists(bookmarkid.ToString()))
            {
                temprange = W_Bkm.get_Item(ref bookmarkid).Range;
                temprange.Select();
            }
            else
            {
                MessageBox.Show("无法定位,可能在Word中已删除了该标签");
            }
        }
Exemplo n.º 26
0
        public void Start()
        {
            try {
                //Make hidden document active to receive selection
                HiddenDoc.Activate();                 //results in a slight application focus loss
            }
            catch (System.Runtime.InteropServices.COMException ex) {
                if (ex.Message == "Object has been deleted.")
                {
                    //Open Blank document, then attach styles *and update
                    HiddenDoc = Globals.ThisAddIn.Application.Documents.Add(ref missing, ref missing, ref missing, ref FalseObj);
                    HiddenDoc.set_AttachedTemplate(ref templateObj);
                    HiddenDoc.UpdateStyles();
                    HiddenDoc.Activate();
                }
                else
                {
                    throw;
                }
            }

            //Remove Continue Bookmark, if exists
            Word.Bookmarks hiddenDocBookmarks = Globals.ThisAddIn.Application.ActiveDocument.Bookmarks;
            if (hiddenDocBookmarks.Exists("Continue"))
            {
                object        deleteMarkObj = "Continue";
                Word.Bookmark deleteMark    = hiddenDocBookmarks.get_Item(ref deleteMarkObj);
                deleteMark.Select();
                deleteMark.Delete();
            }

            //Tell hidden document it has been saved to remove rare prompt to save document
            HiddenDoc.Saved = true;

            //Keep track when started
            started = true;
        }
Exemplo n.º 27
0
        //修改书签
        private void barButtonItem12_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            BM_Word = FrmGHBZTLContents.W_Doc;
            W_Bkm   = BM_Word.Bookmarks;

            if (gridView2.SelectedRowsCount == 0)
            {
                MessageBox.Show("请选择标签");
                return;
            }
            string          bookmarkname = gridView2.GetRowCellDisplayText(this.gridView2.FocusedRowHandle, "MarkName").ToString();
            string          bookmarkid   = gridView2.GetRowCellDisplayText(this.gridView2.FocusedRowHandle, "UID").ToString();
            string          bookmarkdisc = gridView2.GetRowCellDisplayText(this.gridView2.FocusedRowHandle, "MarkDisc").ToString();
            LayoutBookMark  data         = this.gridView2.GetRow(this.gridView2.FocusedRowHandle) as LayoutBookMark;
            FrmEditBookMark tempfebk     = new FrmEditBookMark();

            tempfebk.MarkName = bookmarkname;
            tempfebk.MarkDesc = bookmarkdisc;
            tempfebk.ShowDialog();
            if (tempfebk.DialogResult == DialogResult.OK)
            {
                data.MarkName = tempfebk.MarkName;
                data.MarkDisc = tempfebk.MarkDesc;
                try
                {
                    Common.Services.BaseService.Update <LayoutBookMark>(data);
                    InitGrid2();
                    this.Refresh();
                    MessageBox.Show("修改成功!");
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Exemplo n.º 28
0
        private void сформироватьГрафикЗанятийДляПечатиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Word.Document document = null;
            try
            {
                #region Открываем doc-файл Word из ресурса
                this.Cursor = Cursors.WaitCursor;                                                           // показываем ожидающий курсор, мол - "жди, идет запуск" :)
                Word.Application docApp = new Word.Application();
                var fullName            = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "608au.doc"); // составляем строку для хранения документа во временной папке
                if (File.Exists(fullName) == true)                                                          // проверка на наличие уже существующего файла и его удаление
                {
                    File.Delete(fullName);
                }
                byte[] resource_doc = Properties.Resources.word_test; // находим и считываем документ из ресурса программы
                File.WriteAllBytes(fullName, resource_doc);           // копируем данные из документа байтового масиисва в ресурсах, в документ временной папки
                document = docApp.Documents.Open(fullName, ReadOnly: false, Visible: false);
                document.Activate();
                #endregion
                #region Вставляем текущую дату рассписания
                Word.Bookmarks date_book = document.Bookmarks;
                Word.Range     date_range;
                foreach (Word.Bookmark mark in date_book)
                {
                    date_range      = mark.Range;
                    date_range.Text = label1.Text.ToString();
                }
                #endregion
                #region Записываем расписание пар в таблицу
                Word.Table   table       = docApp.ActiveDocument.Tables[1];
                string       path_file   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Расписание кафедры");
                string       file_rasp   = Path.Combine(path_file, Properties.Settings.Default.date_rasp.ToString("dd.MM.yyyy") + ".txt");
                StreamReader rasp_reader = new StreamReader(file_rasp);

                string bufferfile = "";
                string NamePrep;
                int    i = 4, q = 1;
                while (bufferfile != null)
                {
                    bufferfile = rasp_reader.ReadLine();
                    if ((bufferfile != null) && (bufferfile.IndexOf("#ff00ff\"> ") >= 0))
                    {
                        // сохраняем сокращенное имя препода в хранилище
                        NamePrep   = bufferfile.Substring(bufferfile.IndexOf("COLOR=\"#ff00ff\"> ") + 17, bufferfile.Length - bufferfile.IndexOf("COLOR=\"#ff00ff\"> ") - 28);
                        NamePrep   = NamePrep.Remove(1, NamePrep.IndexOf(" ")); // удаляем лишние символы в строке до пробела (без учета первого символа)
                        NamePrep   = NamePrep.Replace(".", "");                 // удаление оставшегося лишнего символа .
                        bufferfile = rasp_reader.ReadLine();
                        #region 1 неделя
                        while (i <= 44)                                                     // пока не достигли конца таблицы - конца недели
                        {
                            while (bufferfile.IndexOf("SIZE=2><P ALIGN=\"CENTER\">") == -1) // тег для поиска дня недели
                            {
                                bufferfile = rasp_reader.ReadLine();
                            }
                            bufferfile = rasp_reader.ReadLine();
                            while (q <= 6) // счетчик пар
                            {
                                bufferfile = rasp_reader.ReadLine();
                                if ((bufferfile.IndexOf("\">_") == -1) && (bufferfile.IndexOf("а.608а") >= 0))
                                {
                                    table.Rows[i].Cells[3].Range.Text = NamePrep + " - " + bufferfile.Substring(bufferfile.IndexOf("ALIGN=\"CENTER\">") + 15, bufferfile.Length - bufferfile.IndexOf("</F") - 2);
                                }
                                else
                                if ((bufferfile.IndexOf("\">_") == -1) && (bufferfile.IndexOf("а.608б") >= 0))
                                {
                                    table.Rows[i].Cells[4].Range.Text = NamePrep + " - " + bufferfile.Substring(bufferfile.IndexOf("ALIGN=\"CENTER\">") + 15, bufferfile.Length - bufferfile.IndexOf("</F") - 2);
                                }
                                bufferfile = rasp_reader.ReadLine();
                                q++; i++;
                            }
                            i++; q     = 1;
                            bufferfile = rasp_reader.ReadLine();
                        }
                        i = 4;
                        #endregion
                        #region 2 неделя
                        while (i <= 44)
                        {
                            while (bufferfile.IndexOf("SIZE=2 COLOR=\"#0000ff\"><P ALIGN=\"CENTER\">") == -1)
                            {
                                bufferfile = rasp_reader.ReadLine();
                            }
                            bufferfile = rasp_reader.ReadLine();
                            while (q <= 6)
                            {
                                bufferfile = rasp_reader.ReadLine();
                                if ((bufferfile.IndexOf("\"> _") == -1) && (bufferfile.IndexOf("а.608а") >= 0))
                                {
                                    table.Rows[i].Cells[7].Range.Text = NamePrep + " - " + bufferfile.Substring(bufferfile.IndexOf("ALIGN=\"CENTER\">") + 15, bufferfile.Length - bufferfile.IndexOf("</F") - 2);
                                }
                                else
                                if ((bufferfile.IndexOf("\"> _") == -1) && (bufferfile.IndexOf("а.608б") >= 0))
                                {
                                    table.Rows[i].Cells[8].Range.Text = NamePrep + " - " + bufferfile.Substring(bufferfile.IndexOf("ALIGN=\"CENTER\">") + 15, bufferfile.Length - bufferfile.IndexOf("</F") - 2);
                                }
                                bufferfile = rasp_reader.ReadLine();
                                q++; i++;
                            }
                            i++; q     = 1;
                            bufferfile = rasp_reader.ReadLine();
                        }
                        i = 4;
                        #endregion
                    }
                }
                rasp_reader.Dispose();
                #endregion
                this.Cursor    = Cursors.Default;
                docApp.Visible = true;
                document       = null;
            }
            catch (Exception ex)
            {
                // ошибки выводим
                MessageBox.Show("Ошибка при создании документа: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                document = null;
            }
        }
Exemplo n.º 29
0
        private void MakeTicket(string[] param)
        {
            //создание билета
            SqlManager       sqlManager;
            MessageBoxResult res = MessageBox.Show("Вы хотите купить именно этот билет?", "", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (res == MessageBoxResult.Yes)
            {
                Word.Document doc = null;
                try
                {
                    Item item;
                    sqlManager = new SqlManager();
                    if (sqlManager.UpdateActualCountTripsInDB() != -2)
                    {
                        DataTable dt = sqlManager.ReturnTable("SELECT ActualCount " +
                                                              "FROM Tours " +
                                                              "WHERE Name_tour = '" + (SelectedTrips.SelectedItem as Item).NameTour + "'");
                        if (dt != null)
                        {
                            if (Convert.ToInt32(dt.Rows[0].ItemArray[0]) != 0)
                            {
                                //создаем новый документ
                                Word.Application app = new Word.Application();
                                var location         = System.Reflection.Assembly.GetExecutingAssembly().Location;
                                doc = app.Documents.Open(Path.GetDirectoryName(location) + @"\Шаблон.docx");
                                doc.Activate();
                                //открываем шаблон и получаем список закладок
                                Word.Bookmarks       wBookmarks = doc.Bookmarks;
                                Word.Range           wRange; //положение закладки в документе
                                List <Word.Bookmark> bookmarks = new List <Word.Bookmark>();
                                foreach (Word.Bookmark mark in wBookmarks)
                                {
                                    bookmarks.Add(mark);
                                }
                                string[] mass = (DataPerson.right == 3) ? sqlManager.ReturnDataPerson() : param;
                                if (mass != null)
                                {
                                    string[] data = new string[13];
                                    for (int i = 0; i < 6; i++)
                                    {
                                        data[i] = mass[i];
                                    }
                                    item     = Item.items.Find(x => x.NameTour == (SelectedTrips.SelectedItem as Item).NameTour);
                                    data[6]  = item.NameTour;
                                    data[7]  = item.NameCountry;
                                    data[8]  = item.NameCity;
                                    data[9]  = item.DateBegin;
                                    data[10] = item.DateEnd;
                                    data[11] = item.Price.ToString();
                                    data[12] = DateTime.Today.ToShortDateString();
                                    for (int i = 0; i < 13; i++) //заполнение данных на месте закладок
                                    {
                                        wRange      = bookmarks.ElementAt(i).Range;
                                        wRange.Text = data[i];
                                    }
                                    Item.items.Remove(item);
                                    SelectedTrips.Items.Remove(SelectedTrips.SelectedItem);
                                    int flag = sqlManager.ReturnNumber("SELECT Num_Tour FROM Tours WHERE Name_tour = '" + data[6] + "'");
                                    if (flag != -2)
                                    {
                                        int buf = flag;
                                        if (sqlManager.Insert("INSERT INTO Trips(Num_tour, Num_tourist, DateOfBuy) VALUES(" + buf +
                                                              "," + DataPerson.id + ", '" + DateTime.Today.Date + "')") != -2)
                                        {
                                            if ((flag = DataPerson.CountTickets()) != -2)
                                            {
                                                doc.SaveAs(FileName: @"..\Desktop\Ticket" + DataPerson.id + "_" + flag + ".docx");
                                                doc.Close();
                                                doc = null;
                                                MessageBox.Show("Ваш билет готов и находится на рабочем столе", "", MessageBoxButton.OK, MessageBoxImage.Information);
                                                choiseDataGrid.ItemsSource = null;
                                                choiseDataGrid.Visibility  = Visibility.Hidden;
                                                label.Visibility           = Visibility.Hidden;
                                                SelectedTrips.Visibility   = Visibility.Visible;
                                            }
                                            else
                                            {
                                                PagesManager.ShowConnectionError();
                                            }
                                        }
                                        else
                                        {
                                            PagesManager.ShowConnectionError();
                                        }
                                    }
                                    else
                                    {
                                        PagesManager.ShowConnectionError();
                                    }
                                }
                                else
                                {
                                    PagesManager.ShowConnectionError();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Билеты закончились!", "", MessageBoxButton.OK, MessageBoxImage.Warning);
                                item = Item.items.Find(x => x.NameTour == (SelectedTrips.SelectedItem as Item).NameTour);
                                Item.items.Remove(item);
                                SelectedTrips.Items.Remove(SelectedTrips.SelectedItem);
                                choiseDataGrid.ItemsSource = null;
                                choiseDataGrid.Visibility  = Visibility.Hidden;
                                label.Visibility           = Visibility.Hidden;
                                SelectedTrips.Visibility   = Visibility.Visible;
                            }
                            System.GC.Collect();
                        }
                        else
                        {
                            PagesManager.ShowConnectionError();
                        }
                    }
                    else
                    {
                        PagesManager.ShowConnectionError();
                    }
                }
                catch (Exception ex)
                {
                    doc.Close();
                    doc = null;
                    Console.WriteLine("Во время выполнения произошла ошибка! " + ex.Message);
                }
            }
        }
Exemplo n.º 30
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            BM_Word = FrmGHBZTLContents.W_Doc;
            W_Bkm   = BM_Word.Bookmarks;
            if (BM_Word.Application.Selection.Range.Text == null)
            {
                MessageBox.Show("请选择添加书签的文本!");
                return;
            }
            if (txtMarkName.Text.Length == 0)
            {
                MessageBox.Show("请输入书签名称!");
                txtMarkName.Focus();
                return;
            }
            LayoutBookMark lbm = new LayoutBookMark();

            lbm.UID      = "B_M_" + lbm.UID;
            lbm.LayoutID = FrmGHBZTLContents.LayoutID;
            lbm.MarkName = txtMarkName.Text;
            lbm.MarkDisc = txtMarkDisc.Text;
            if (chbType.Checked)
            {
                lbm.MarkType = "程序员";
            }
            else
            {
                lbm.MarkType = "用户";
            }
            Word.Range tmpRng = BM_Word.Application.Selection.Range;
            if (tmpRng.Bookmarks.Count > 0)
            {
                MessageBox.Show(tmpRng.Text + " 已是书签或包含已有书签!");
                return;
            }
            object oRng = tmpRng;

            W_Bkm.Add(lbm.UID.ToString(), ref oRng);
            object markid = lbm.UID.ToString();

            Word.Bookmark tempbk = W_Bkm.get_Item(ref markid);
            tempbk.Range.Font.Color = Word.WdColor.wdColorBlue;
            lbm.StartP = tempbk.Start;
            if (tempbk.Range.Text.Length > 140)
            {
                lbm.MarkText = tempbk.Range.Text.Substring(0, 140);
            }
            else
            {
                lbm.MarkText = tempbk.Range.Text;
            }
            try
            {
                Common.Services.BaseService.Create <LayoutBookMark>(lbm);
            }
            catch (Exception)
            {
                throw;
            }
            FrmBookMark.Parentfrm.InitGrid2();
            FrmBookMark.Parentfrm.Refresh();
            MessageBox.Show("书签添加成功!");
            //保存word
            FrmGHBZTLContents.ParentForm.SaveData_Word();
            txtMarkName.Text = "";
            txtMarkDisc.Text = "";
            txtMarkName.Focus();
        }
Exemplo n.º 31
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            BM_Word = FrmGHBZTLContents.W_Doc;
            W_Bkm = BM_Word.Bookmarks;
            if (BM_Word.Application.Selection.Range.Text == null)
            {
                MessageBox.Show("��ѡ�������ǩ���ı�!");
                return;
            }
            if (txtMarkName.Text.Length == 0)
            {
                MessageBox.Show("��������ǩ����!");
                txtMarkName.Focus();
                return;
            }
            LayoutBookMark lbm = new LayoutBookMark();
            lbm.UID = "B_M_" + lbm.UID;
            lbm.LayoutID = FrmGHBZTLContents.LayoutID;
            lbm.MarkName = txtMarkName.Text;
            lbm.MarkDisc = txtMarkDisc.Text;
            if (chbType.Checked)
            {
                lbm.MarkType = "����Ա";
            }
            else
            {
                lbm.MarkType = "�û�";
            }
            Word.Range tmpRng = BM_Word.Application.Selection.Range;
            if (tmpRng.Bookmarks.Count > 0)
            {
                MessageBox.Show(tmpRng.Text + " ������ǩ�����������ǩ!");
                return;
            }
            object oRng = tmpRng;
            W_Bkm.Add(lbm.UID.ToString(), ref oRng);
            object markid = lbm.UID.ToString();
            Word.Bookmark tempbk = W_Bkm.get_Item(ref markid);
            tempbk.Range.Font.Color = Word.WdColor.wdColorBlue;
            lbm.StartP = tempbk.Start;
            if (tempbk.Range.Text.Length > 140)
            {
                lbm.MarkText = tempbk.Range.Text.Substring(0, 140);
            }
            else
            {
                lbm.MarkText = tempbk.Range.Text;
            }
            try
            {
                Common.Services.BaseService.Create<LayoutBookMark>(lbm);
            }
            catch (Exception)
            {

                throw;
            }
            FrmBookMark.Parentfrm.InitGrid2();
            FrmBookMark.Parentfrm.Refresh();
            MessageBox.Show("��ǩ��ӳɹ���");
            //����word
            FrmGHBZTLContents.ParentForm.SaveData_Word();
            txtMarkName.Text = "";
            txtMarkDisc.Text = "";
            txtMarkName.Focus();
        }
Exemplo n.º 32
0
 //private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 //{
 //    if (treeList1.Nodes.Count>0)
 //    {
 //        FrmGHBGdata fgh = new FrmGHBGdata();
 //        fgh.ShowDialog();
 //        if (fgh.DialogResult==DialogResult.OK)
 //        {
 //            string year = fgh.GHBGyear;
 //            MessageBox.Show("ѡ��Ĺ滮��������ǣ�" + fgh.GHBGyear);
 //           // RefrehDataAll(year);
 //            W_Doc = (Word.Document)dsoFramerWordControl1.AxFramerControl.ActiveDocument;
 //            W_Bkm = W_Doc.Bookmarks;
 //            Refreh_Chapter2(year,W_Bkm,"�ֶ�");
 //        }
 //    }
 //}
 private void RefrehDataAll(string year,string type,string liexing)
 {
     //ÿ���������һ��
        for (int i = 0; i < treeList1.Nodes.Count; i++)
        {
        if (RefFalg==false)
        {
            return;
        }
        //����һ�����
        treeList1.FocusedNode = treeList1.Nodes[i];
        W_Doc = (Word.Document)dsoFramerWordControl1.AxFramerControl.ActiveDocument;
        W_Bkm = W_Doc.Bookmarks;
        string chaptername=treeList1.FocusedNode["ChapterName"].ToString();
        Change_Data_byChapter(chaptername, year, W_Bkm, type,liexing);
        if (treeList1.Nodes[i].Nodes.Count > 0)
        {
            //�����������
            for (int k = 0; k < treeList1.Nodes[i].Nodes.Count; k++)
            {
                if (RefFalg == false)
                {
                    return;
                }
                treeList1.FocusedNode = treeList1.Nodes[i].Nodes[k];
                W_Doc = (Word.Document)dsoFramerWordControl1.AxFramerControl.ActiveDocument;
                W_Bkm = W_Doc.Bookmarks;
                chaptername = treeList1.FocusedNode["ChapterName"].ToString();
                Change_Data_byChapter(chaptername, year, W_Bkm, type, liexing);
            }
        }
        }
        if (type == "�Զ�")
     {
         MessageBox.Show("����ɸ��£�");
     }
 }