Thank you :) but i am not able to goto the bookmark and bookmark names are not displayed(dont know whether i had inserted bookmarks correctly,please check).Following is the code: Word._Application oWord; Word._Document oDoc; oWord = new Word.Application(); oWord.Visible = true; object fileName = strFileName; object readOnly = false; object isVisible = true; object missing = System.Reflection.Missing.Value; object oEndOfDoc = "\\endofdoc"; oDoc = oWord.Documents.Open(ref fileName, 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); oDoc.Activate(); Word.Paragraph oPara1; oPara1 = oDoc.Content.Paragraphs.Add(ref missing); oPara1.Range.Text = "Heading 1"; oPara1.Range.Font.Bold = 1; oPara1.Format.SpaceAfter = 24; oPara1.Range.InsertParagraphAfter(); Word.Paragraph oPara2; object oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range; oPara2 = oDoc.Content.Paragraphs.Add(ref oRng); oPara2.Range.Text = "Heading 2"; oPara2.Format.SpaceAfter = 6; oPara2.Range.InsertParagraphAfter(); Word.Paragraph oPara3; oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range; oPara3 = oDoc.Content.Paragraphs.Add(ref oRng); oPara3.Range.Text = "This is a sentence of normal text.Now here is a text"; oPara3.Range.Font.Bold = 0; oPara3.Format.SpaceAfter = 24; oPara3.Range.InsertParagraphAfter(); oDoc.Paragraphs[1].Range.InsertParagraphBefore(); object bm1 = oDoc.Paragraphs[1].Range; Microsoft.Office.Interop.Word.Bookmark bookmark1 = oDoc.Bookmarks.Add("bookmark1", ref bm1); bookmark1.Range.Text = "bm1"; oDoc.Paragraphs[2].Range.InsertParagraphBefore(); object bm2 = oDoc.Paragraphs[2].Range; Microsoft.Office.Interop.Word.Bookmark bookmark2 = oDoc.Bookmarks.Add("bookmark2", ref bm2); bookmark1.Range.Text = "bm2"; int nCount; nCount = oDoc.Bookmarks.Count; for (int i = 0; i < nCount; i++) { object objI = i; MessageBox.Show(oDoc.Bookmarks.get_Item(ref objI).Name); }
Jia100
Posts
-
Reading bookmarks in word -
Reading bookmarks in wordHow to open a document using word automation and read the bookmark values in it?This has to be done as a function...input of the function will be the full path of the file to be opened and a list of bookmark names.
-
Break point not hit error in VS2005Stefan63 wrote: first deleted the obj files and then rebuilt the project Yes done like that...not in any function breakpoints are working..same issue everywhere...
-
Break point not hit error in VS2005Thank you...the function that has been put break point is still used..debugging was working fine until i cleaned and rebuild the project & also deleted .obj files.The language is VC++ with some C++ also used in coding and working on VS2005...now i had attached to script and trying to debug but the control is not coming to the break point..only the break point not hit that error is removed...i mean the symbol showing error is not coming now.
-
Break point not hit error in VS2005It is an exe..yes it is relaying some dlls and i had placed a breakpoint is in the relevant project itself...but not working.
-
Break point not hit error in VS2005Thank you...Yes they are set..but the issue is still there.Earlier i had removed the .obj files from the debug folder..cleaned and rebuild the whole project after that this problem is occurring.
-
Break point not hit error in VS2005Not able to debug my project it is shown as 'The breakpoint will not currently be hit.No symbols have been loaded for this document.'The break point is shown as an error symbol.Along with it showing another project's function name.I am using VC2005.How to solve this?
-
Debugging problemSorry i think this is not the expected answer....
-
Debugging problemI have to debug two projects which are of different versions..started debugging from VC2008 to VC6.In 2008 from a function to another function in vc6.In vc2008 showing correct values but in vc6 not showing any values both strings & numbers.The output VC6 code is a dll.What to do?Pls help....
modified on Friday, December 17, 2010 7:15 AM
-
CString::Replace() problemThis is the part of a parser...so first cleaning the sentence.The input will be .rtf documents.For example if there is a sentence like Name:XXXX,HomeLoc:WF etc. it will be the text that will be got from the document.So these symbols like ':' are replaced by like that i had mentioned before.The desired output should be like...Name<scol>XXXX <comma>HomeLoc<scol>WF etc.Hope now the question is clear.
-
CString::Replace() problemk..but then also the problem is not solved...hw can i modify the code to get the whole string replaced properly?
-
CString::Replace() problemThis is the function where it is done.... BOOL CProcessData::CleanSentence(CString Sentence, BOOL bPreserveComma) { CString csTemp=Sentence; m_txtCrntStatus->SetWindowText("Cleaning Sentence"); csTemp.Replace("!"," "); csTemp.Replace("<"," "); csTemp.Replace(">"," "); csTemp.Replace("?"," "); csTemp.Replace(";"," "); csTemp.Replace("'"," "); csTemp.Replace("{"," "); csTemp.Replace("}"," "); if(bPreserveComma) { while(csTemp.Replace(","," <comma> ")); while(csTemp.Replace(":"," <scol> ")); } else { while(csTemp.Replace("<comma>","")); } while(csTemp.Replace("\t"," ")); while(csTemp.Replace("\r","")); while(csTemp.Replace("\n","")); while(csTemp.Replace(" "," ")); int nLen =csTemp.GetLength(); if(nLen<2) { while(csTemp.Replace(" ","")); } nLen =csTemp.GetLength(); if(nLen<=0) { return FALSE; } SentenceSplitter(csTemp); return TRUE; }
-
CString::Replace() problemActually these replacement codes are in the same function so they are done back to back...so how can we run them individually?We are taking paragraphs as input & the splitted sentence is actually the strings we are replacing....
modified on Monday, December 6, 2010 3:06 AM
-
CString::Replace() problemI am using a code while(csTemp.Replace(":"," <scol> ")).Before this some other locs are also there to replace some other signs,but after some replacement due to this code some string is truncated in the buffer i think...so that rest of the string is not replaced.Pls suggest a solution for this....