예제 #1
0
        private void FillMonth()
        {
            String curDate = curentDate.ToString("MMMM", CultureInfo.CurrentCulture).ToUpper();

            Word.Bookmark bookmark = word.FindBookMark(dateBookMark);
            bookmark.Range.Text = curDate;
        }
예제 #2
0
        private void MoveText(CardControl TOPCARD, CardControl BOTTOMCARD)
        {
            //Globals.ThisAddIn.userControlWPF.ListCardControls.IndexOf(card)


            if (int.Parse(BOTTOMCARD.IDfield) != 1)// if it is not the first card
            {
                string nobookmark = "None";

                if ((TOPCARD.Bookmarkfield.ToUpper() != nobookmark.ToUpper()) && (BOTTOMCARD.Bookmarkfield.ToUpper() != nobookmark.ToUpper()))     // only if both are linked to a bookmark - to upper to maintain compatibility with old format
                {
                    Word.Bookmark TOPbmk   = Globals.ThisAddIn.Application.ActiveDocument.Bookmarks[TOPCARD.Bookmarkfield];
                    Word.Range    TOPRange = TOPbmk.Range;

                    // move the text
                    Word.Bookmark BOTTOMbmk   = Globals.ThisAddIn.Application.ActiveDocument.Bookmarks[BOTTOMCARD.Bookmarkfield];
                    Word.Range    BOTTOMRange = BOTTOMbmk.Range;
                    BOTTOMRange.Cut();

                    Word.Range temprange         = Globals.ThisAddIn.Application.ActiveDocument.Range(TOPRange.Start, TOPRange.End); // store range of prevbookmark
                    int        topbookmarkLenght = TOPRange.End - TOPRange.Start;                                                    // calculate lenght of prevbookmark subtracting end and start
                    string     topbkmName        = TOPbmk.Name;                                                                      // save name of prevbookmark
                    TOPbmk.Delete();                                                                                                 // delete prevbookmark
                    // add a temporary space character at the start of the previous bookmark
                    // paste the text
                    Word.Range newrange = Globals.ThisAddIn.Application.ActiveDocument.Range(temprange.Start, temprange.Start);
                    newrange.Paste();
                    Word.Range    newbkmrkrange = Globals.ThisAddIn.Application.ActiveDocument.Range(newrange.End, newrange.End + topbookmarkLenght);
                    Word.Bookmark newbookmark   = Globals.ThisAddIn.Application.ActiveDocument.Bookmarks.Add(topbkmName, newbkmrkrange);  // create new bookmark with start at the end of the bookmark and end at start+lenght

                    //BOTTOMbmk.Range.Select();
                }
            }
        }
예제 #3
0
        public void CopyToFileTextOnly_Test_DoesNotKeepHyperlinksAndBookmarks()
        {
            Range        range        = _application.Documents.Add().Range();
            const string bookmarkName = "bookmark1";

            Interop.Paragraph paragraph1 = range.Paragraphs.Add();
            paragraph1.Range.Text = "bookmark";
            Interop.Bookmark bookmark = paragraph1.Range.Bookmarks.Add(bookmarkName);

            range.Paragraphs.Add();
            Interop.Paragraph paragraph2 = range.Paragraphs.Add();
            paragraph2.Range.Text = "link";
            range.Hyperlinks.Add(paragraph2.Range, SubAddress: bookmark);

            _tmpFile = new OpenXmlHelper().CopyToFileTextOnly(range);

            using (WordprocessingDocument doc = WordprocessingDocument.Open(_tmpFile, true)) {
                OpenXml.Body body = doc.MainDocumentPart
                                    .Document
                                    .Body;

                CollectionAssert.IsEmpty(body.Descendants <OpenXml.BookmarkStart>());
                CollectionAssert.IsEmpty(body.Descendants <OpenXml.Hyperlink>());
            }
        }
예제 #4
0
 private void simpleButton3_Click(object sender, EventArgs e)
 {
     if (num < marklist.Count - 1)
     {
         num = num + 1;;
         if (W_Bkm.Exists(marklist[num].UID.ToString()))
         {
             object tempid = marklist[num].UID.ToString();
             tempmk = W_Bkm.get_Item(ref tempid);
             tempmk.Select();
             oldstr      = tempmk.Range.Text;
             txtold.Text = oldstr;
             if (mkd.FindStr(marklist[num].UID.ToString()) != -1)
             {
                 txtnew.Text = mkd.Data[mkd.FindStr(marklist[num].UID.ToString())].BQdata.ToString();
                 newstr      = txtnew.Text;
                 txtnew.SelectAll();
             }
             else
             {
                 newstr      = "暂无值";
                 txtnew.Text = newstr;
                 txtnew.SelectAll();
             }
         }
         gridRefreh();
     }
     else
     {
         MessageBox.Show("已到书签结尾!");
     }
 }
예제 #5
0
        private void Frm_FindandChangeTL_Load(object sender, EventArgs e)
        {
            adddata();
            string conn = "LayoutID='" + layoutID + "' order by StartP";
            IList <LayoutBookMark> templist = Common.Services.BaseService.GetList <LayoutBookMark>("SelectLayoutBookMarkList", conn);

            marklist = templist;
            if (marklist.Count == 0)
            {
                MessageBox.Show("无书签!请先添加书签");
                this.Close();
                return;
            }
            if (W_Bkm.Exists(marklist[0].UID.ToString()))
            {
                object tempid = marklist[0].UID.ToString();
                tempmk = W_Bkm.get_Item(ref tempid);
                tempmk.Select();
                oldstr      = tempmk.Range.Text;
                txtold.Text = oldstr;
                if (mkd.FindStr(marklist[0].UID.ToString()) != -1)
                {
                    txtnew.Text = mkd.Data[mkd.FindStr(marklist[0].UID.ToString())].BQdata.ToString();
                    data_object = mkd.Data[mkd.FindStr(marklist[0].UID.ToString())].BQdata;
                    newstr      = txtnew.Text;
                }
                else
                {
                    newstr      = "暂无值";
                    txtnew.Text = newstr;
                    txtnew.SelectAll();
                }
            }
        }
예제 #6
0
        public Document AddTable(Document document, TableProperties properties)
        {
            if (properties.Students.Count() == 0)
            {
                return(null);
            }

            this.document = OpenDocument(document);
            Word.Range range;

            if (!string.IsNullOrEmpty(properties.Bookmark))
            {
                Word.Bookmark bm = this.document.Bookmarks[properties.Bookmark];
                range = bm.Range;
            }
            else
            {
                range = this.document.Range(0, 0);
            }

            this.document.Tables.Add(range, properties.NumRows, properties.NumColumns);
            CreateTable(properties);
            this.document.Save();
            document.File = SaveDoc();
            return(document);
        }
예제 #7
0
        private static void FillRangeByReceiveInfo(Word.Document dct, Word.Bookmark bookMark,
                                                   string userId, string userName)
        {
            if (userId == string.Empty)
            {
                return;
            }

            string signFileName = GetStaffSignFileName(userId);

            if (signFileName == string.Empty)
            {
                //如果没有下载到签名文件,则填写姓名
                bookMark.Range.Text = userName;
            }
            else
            {
                object range = bookMark.Range;

                Word.InlineShape shape = dct.InlineShapes.AddPicture(signFileName,
                                                                     false, true, ref range);
                shape.Width  = XUICommon.SystemConfigInfo.SignWidht;
                shape.Height = XUICommon.SystemConfigInfo.SignHeight;
            }
        }
예제 #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);
            }
        }
        public void CopyToFile_Test_CopiesCorrectHyperlinks_WithMissingBookmarks()
        {
            Range        range        = _application.Documents.Add().Range();
            const string bookmarkName = "bookmark1";

            Interop.Paragraph paragraph1 = range.Paragraphs.Add();
            paragraph1.Range.Text = "bookmark";
            Interop.Bookmark bookmark = paragraph1.Range.Bookmarks.Add(bookmarkName);

            range.Paragraphs.Add();
            Interop.Paragraph paragraph2 = range.Paragraphs.Add();
            paragraph2.Range.Text = "link";
            range.Hyperlinks.Add(paragraph2.Range, SubAddress: bookmark);

            _tmpFile = new OpenXmlHelper().CopyToFile(paragraph2.Range);
            _application.DisplayAlerts = Interop.WdAlertLevel.wdAlertsNone;
            _application.Windows[1].Close(Interop.WdSaveOptions.wdDoNotSaveChanges);

            using (WordprocessingDocument doc = WordprocessingDocument.Open(_tmpFile, true)) {
                OpenXml.Hyperlink hyperlink = doc.MainDocumentPart
                                              .Document
                                              .Body
                                              .Descendants <OpenXml.Hyperlink>()
                                              .First();

                Assert.That(hyperlink.Anchor.Value, Is.EqualTo(bookmarkName));
            }
        }
        public void CopyToFile_Test_CopiesCorrectHyperlinksToBookmarks()
        {
            Range        range        = _application.Documents.Add().Range();
            const string bookmarkName = "bookmark1";

            Interop.Paragraph paragraph1 = range.Paragraphs.Add();
            paragraph1.Range.Text = "bookmark";
            Interop.Bookmark bookmark = paragraph1.Range.Bookmarks.Add(bookmarkName);

            range.Paragraphs.Add();
            Interop.Paragraph paragraph2 = range.Paragraphs.Add();
            paragraph2.Range.Text = "link";
            range.Hyperlinks.Add(paragraph2.Range, SubAddress: bookmark);

            _tmpFile = new OpenXmlHelper().CopyToFile(range);

            using (WordprocessingDocument doc = WordprocessingDocument.Open(_tmpFile, true)) {
                OpenXml.Body body = doc.MainDocumentPart
                                    .Document
                                    .Body;

                OpenXml.BookmarkStart bookmarkStart = body.Descendants <OpenXml.BookmarkStart>().First();
                OpenXml.Hyperlink     hyperlink     = body.Descendants <OpenXml.Hyperlink>().First();

                Assert.That(bookmarkStart.Name.Value, Is.EqualTo(bookmarkName));
                Assert.That(hyperlink.Anchor.Value, Is.EqualTo(bookmarkName));
            }
        }
예제 #11
0
        private static void FillRange(Word.Document dct, Word.Bookmark bookMark,
                                      XVEquipmentReceiveInfo receiveInfo)
        {
            string userId   = string.Empty;
            string userName = string.Empty;

            switch (bookMark.Name)
            {
            case "检定员":
                userId   = receiveInfo.CheckedUserId;
                userName = receiveInfo.CheckedUserName;
                // bookMark.Range.Text = receiveInfo.CheckedUserName;
                break;

            case "核验员":
                userId   = receiveInfo.VerifyedUserId;
                userName = receiveInfo.VerifyedUserName;
                //bookMark.Range.Text = receiveInfo.VerifyedUserName;
                break;

            case "签发员":
                userId   = receiveInfo.SignedUserId;
                userName = receiveInfo.SignedUserName;
                //bookMark.Range.Text = receiveInfo.SignedUserName;
                break;

            case "收发员":
                userId   = receiveInfo.DispatchUserId;
                userName = receiveInfo.DispatchUserName;
                //bookMark.Range.Text = receiveInfo.DispatchUserName;
                break;
            }

            FillRangeByReceiveInfo(dct, bookMark, userId, userName);
        }
예제 #12
0
 public void updateBookmark(string bookmarkToBeUpdated, string newText, Microsoft.Office.Interop.Word.Document document)
 {
     //Object name = "militar";
     //Microsoft.Office.Interop.Word.Range range = document.Bookmarks.get_Item(ref name).Range;
     Microsoft.Office.Interop.Word.Bookmark bookmark = document.Bookmarks.get_Item("militar");
     MessageBox.Show(bookmark.Range.Text);
 }
예제 #13
0
        private void FillDate()
        {
            DateTime date    = DateTime.Now;
            String   curDate = date.ToString("dd.MM.yyyy", CultureInfo.CurrentCulture);

            Word.Bookmark bookmark = word.FindBookMark(dateBookMark);
            bookmark.Range.Text = curDate;
        }
예제 #14
0
        private void FillGuard3(GuardManager manager)
        {
            Word.Bookmark bookmark = word.FindBookMark(guard3);
            Guard         guard    = manager.GetGuard3();

            bookmark.Select();
            FillGuard(guard, bookmark.Range);
        }
예제 #15
0
        //Процедура замена в документе данных закладок на текст из программы
        internal void BookMarkReplaceNative(Word.Bookmark bookmark, string newText)
        {
            object rng          = bookmark.Range;
            string bookmarkName = bookmark.Name;

            bookmark.Range.Text = newText;

            //  Word.Document document = this.Application.ActiveDocument;
            //  document.Bookmarks.Add(bookmarkName, ref rng);
        }
예제 #16
0
파일: Word.cs 프로젝트: Zagii/EAkzg
        public void wstawTytulRozdzialu(object bookmark, String tekst, String styl)
        {
            Wordy.Paragraph par = null;
            Wordy.Range     rng;

            Wordy.Bookmark book = doc.Bookmarks.get_Item(ref bookmark);

            rng = book.Range;

            rng.Select();
            //wordApp.ActiveDocument.Content.InsertParagraphBefore();
            //  rng.Collapse(Microsoft.Office.Interop.Word.WdCollapseDirection.wdCollapseEnd) ;
            rng.Select();
            object p = rng.End;
            object k = rng.End;

            String styl_txt = "HLD_normalny";

            if (styl == "1")
            {
                styl_txt = "HLD_tytul_rozdzialu";
            }
            if (styl == "2")
            {
                styl_txt = "HLD_tytul_podrozdzialu";
            }
            if (styl == "3")
            {
                styl_txt = "HLD_tytul_podrozdzialu";
            }


            object indentStyle = styl_txt;

            book.Range.InsertAfter(tekst + "\n");

            p   = book.Range.End;
            k   = book.Range.End + tekst.Length + 1;
            rng = doc.Range(ref p, ref k);
            rng.Select();
            rng.set_Style(indentStyle);

            book.Range.Select();
            p   = book.Range.Start;
            k   = rng.End;
            rng = doc.Range(ref p, ref k);
            rng.Select();
            object r = rng;

            doc.Bookmarks.Add((String)bookmark, ref r);
            book = doc.Bookmarks.get_Item(ref bookmark);

            book.Range.Select();
        }
예제 #17
0
        public void AddBookmarkToBookmark(string name, string newName)
        {
            if (!_document.Bookmarks.Exists(name))
            {
                return;
            }

            WordOM.Bookmark cBookmark = _document.Bookmarks[name];
            cBookmark.Copy(newName);
            //var nBookmark = _document.Application.Selection.Bookmarks.Add(newName);
        }
예제 #18
0
 /// <summary>
 /// UPdates a bookmark in the word document
 /// </summary>
 /// <param name="bookMarkName">name of the bookmark to update</param>
 /// <param name="oDoc">the word document</param>
 /// <param name="value">the value to set the bookmark to</param>
 /// <returns></returns>
 private bool UpdateBookmark(string bookMarkName, Word.Document oDoc, string value)
 {
     Word.Bookmark bookMark = null;
     if (FindBookMark(bookMarkName, oDoc, ref bookMark))
     {
         bookMark.Range.Text = value;
         return(true);
     }
     m_logger("Unable to find bookmark to update: " + bookMarkName);
     return(false);
 }
예제 #19
0
 public Wd.Table FindTable(Wd.Document doc, Wd.Bookmark bm)
 {
     foreach (Wd.Table t in doc.Tables)
     {
         if (bm.Range.Start >= t.Range.Start && bm.Range.End <= t.Range.End)
         {
             return(t);
         }
     }
     return(null);
 }
예제 #20
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";
        }
예제 #21
0
        public Word.Bookmark FindBookMark(String bookmarkName)
        {
            if (_document.Bookmarks.Exists(bookmarkName))
            {
                // обьектные строки для Word
                object bookmarkNameObj = bookmarkName;

                Word.Bookmark bookmark = _document.Bookmarks.get_Item(ref bookmarkNameObj);
                return(bookmark);
            }
            throw new ArgumentException("Закладка не найдена");
        }
예제 #22
0
        //</Snippet64>


        //---------------------------------------------------------------------
        //<Snippet65>
        internal void BookMarkReplaceNative(
            Word.Bookmark bookmark,
            string newText)
        {
            //</Snippet65>
            //<Snippet66>
            object rng          = bookmark.Range;
            string bookmarkName = bookmark.Name;

            bookmark.Range.Text = newText;

            this.Bookmarks.Add(bookmarkName, ref rng);
        }
예제 #23
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";
        }
예제 #24
0
        private bool FindBookMark(string bookMarkName, Word.Document oDoc, ref Word.Bookmark bookMark)
        {
            bookMark = null;

            foreach (Word.Bookmark item in oDoc.Bookmarks)
            {
                if (item.Name == bookMarkName)
                {
                    bookMark = item;
                    return(true);
                }
            }
            return(false);
        }
예제 #25
0
        internal Microsoft.Office.Interop.Word.Table GetClosestTable(Microsoft.Office.Interop.Word.Bookmark bookmark)
        {
            List <Table> tables = new List <Table>();

            foreach (Microsoft.Office.Interop.Word.Table item in _document.Tables)
            {
                if (item.Range.Start <= bookmark.Range.Start && item.Range.End >= bookmark.Range.End)
                {
                    tables.Add(item);
                }
            }

            return(tables.OrderByDescending(t => t.Range.Start).FirstOrDefault());
        }
예제 #26
0
        private string ImportPdeTag(Word.Document wDoc, string key, string value)
        {
            if (wDoc == null || string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(value))
            {
                return(string.Empty);
            }

            // add a space before text.
            wDoc.Application.Selection.TypeText(" ");

            // add select text
            string bmValue = MarkupUtilities.GenTextXslTag(value, XsltType.Select, true);

            wDoc.Application.Selection.TypeText(bmValue);
            wDoc.Application.Selection.MoveLeft(Word.WdUnits.wdCharacter, bmValue.Length, Word.WdMovementType.wdExtend);

            // add select bookmark
            string bmName = Core.MarkupConstant.MarkupPdeTag + key;

            Word.Bookmark oldBm = null;
            foreach (Word.Bookmark bookmark in wDoc.Bookmarks)
            {
                if (string.Equals(bmName, bookmark.Name, StringComparison.OrdinalIgnoreCase))
                {
                    oldBm = bookmark;
                    break;
                }
            }
            if (oldBm != null)
            {
                oldBm.Delete();
            }
            Word.Range range = wDoc.Application.Selection.Range;
            wDoc.Bookmarks.Add(bmName, range);
            wDoc.Bookmarks.DefaultSorting = Word.WdBookmarkSortBy.wdSortByLocation;
            wDoc.Bookmarks.ShowHidden     = false;

            // set cursor after bookmark
            wDoc.Application.Selection.MoveRight(Word.WdUnits.wdCharacter, 1);

            // markup ProntoDoc;
            WKL.DataController.MainController.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo.IsProntoDoc = true;
            if (!System.IO.File.Exists(wDoc.FullName))
            {
                wDoc.Application.Options.SaveInterval = 0;
            }

            return(bmName);
        }
예제 #27
0
파일: Jinxiu.cs 프로젝트: mhy123152/MyVSTO
        public static Word.Bookmark GetBookmark(Document doc, String bookmarkName)
        {
            // Find bookmark
            Word.Bookmark bookmark = null;
            foreach (Word.Bookmark curBookmark in doc.Bookmarks)
            {
                if (curBookmark.Name.Equals(bookmarkName, StringComparison.OrdinalIgnoreCase))
                {
                    bookmark = curBookmark;
                    break;
                }
            }

            return(bookmark);
        }
예제 #28
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);
        }
예제 #29
0
        /// <summary>
        /// 光标移动到指定书签位置,书签不存在时不移动
        /// </summary>
        /// <param name="bookMarkName"></param>
        /// <returns></returns>
        public bool GoToBookMark(string bookMarkName)
        {
            //是否存在书签
            if (_wordDocument.Bookmarks.Exists(bookMarkName))
            {
                //object what = Word.WdGoToItem.wdGoToBookmark;
                //object name = bookMarkName;
                //GoTo(what, _missing, _missing, name);

                Word.Bookmark bookmark = _wordDocument.Bookmarks.get_Item(bookMarkName);
                bookmark.Select();

                return(true);
            }
            return(false);
        }
예제 #30
0
        private void Application_DocumentOpen2(Microsoft.Office.Interop.Word.Document Doc)
        {
            //<Snippet5>
            if (this.Application.ActiveDocument.Bookmarks.Count > 0)
            {
                object        index         = 1;
                Word.Bookmark firstBookmark = this.Application.ActiveDocument.Bookmarks.get_Item(ref index);


                Document extendedDocument = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);

                Bookmark vstoBookmark = extendedDocument.Controls.AddBookmark(
                    firstBookmark, "VSTOBookmark");
            }
            //</Snippet5>
        }
예제 #31
0
 private void simpleButton1_Click(object sender, EventArgs e)
 {
     object tempid = tempmk.Name.ToString();
      Word.Range tmpRng = tempmk.Range;
      tmpRng.Text = txtnew.Text;
      object oRng = tmpRng;
      W_Bkm.Add(tempid.ToString(), ref oRng);
      if (txtold.Text == txtnew.Text)
      {
          tmpRng.Font.Color = Word.WdColor.wdColorGold;
      }
      if (num >= marklist.Count - 1)
      {
          MessageBox.Show("��ǩ�ѵ���β");
          return;
      }
      num = num + 1; ;
      if (W_Bkm.Exists(marklist[num].UID.ToString()))
      {
          object tempid2 = marklist[num].UID.ToString();
          tempmk = W_Bkm.get_Item(ref tempid2);
          tempmk.Select();
          oldstr = tempmk.Range.Text;
          txtold.Text = oldstr;
          if (mkd.FindStr(marklist[num].UID.ToString()) != -1)
          {
              txtnew.Text = mkd.Data[mkd.FindStr(marklist[num].UID.ToString())].BQdata.ToString();
              newstr = txtnew.Text;
              txtnew.SelectAll();
          }
          else
          {
              newstr = "����ֵ";
              txtnew.Text = newstr;
              txtnew.SelectAll();
          }
      }
      gridRefreh();
 }
예제 #32
0
 private void simpleButton3_Click(object sender, EventArgs e)
 {
     if (num < marklist.Count - 1)
      {
          num = num + 1; ;
          if (W_Bkm.Exists(marklist[num].UID.ToString()))
          {
              object tempid = marklist[num].UID.ToString();
              tempmk = W_Bkm.get_Item(ref tempid);
              tempmk.Select();
              oldstr = tempmk.Range.Text;
              txtold.Text = oldstr;
              if (mkd.FindStr(marklist[num].UID.ToString()) != -1)
              {
                  txtnew.Text = mkd.Data[mkd.FindStr(marklist[num].UID.ToString())].BQdata.ToString();
                  newstr = txtnew.Text;
                  txtnew.SelectAll();
              }
              else
              {
                  newstr = "����ֵ";
                  txtnew.Text = newstr;
                  txtnew.SelectAll();
              }
          }
          gridRefreh();
      }
      else
      {
          MessageBox.Show("�ѵ���ǩ��β��");
      }
 }
예제 #33
0
 private void Frm_FindandChangeTL_Load(object sender, EventArgs e)
 {
     adddata();
     string conn = "LayoutID='" + layoutID + "' order by StartP";
     IList<LayoutBookMark> templist = Common.Services.BaseService.GetList<LayoutBookMark>("SelectLayoutBookMarkList", conn);
     marklist = templist;
     if (marklist.Count==0)
     {
         MessageBox.Show("����ǩ�����������ǩ");
         this.Close();
         return;
     }
     if (W_Bkm.Exists(marklist[0].UID.ToString()))
     {
         object tempid = marklist[0].UID.ToString();
         tempmk = W_Bkm.get_Item(ref tempid);
         tempmk.Select();
         oldstr = tempmk.Range.Text;
         txtold.Text = oldstr;
         if (mkd.FindStr(marklist[0].UID.ToString())!=-1)
         {
             txtnew.Text = mkd.Data[mkd.FindStr(marklist[0].UID.ToString())].BQdata.ToString();
             data_object = mkd.Data[mkd.FindStr(marklist[0].UID.ToString())].BQdata;
             newstr = txtnew.Text;
         }
         else
         {
             newstr = "����ֵ";
             txtnew.Text = newstr;
             txtnew.SelectAll();
         }
     }
 }