I am not able to search Hidden Styles in word using VSTO c#.
I have two styles "Instructions" and "Guidance" in my word document.
Here I used code:
- public bool CheckInstructionText()
- {
- try
- {
- istoCheckInstructionsandGuidence = false;
- bool ischeckforInstructions = false;
- bool ischeckforGuidence = false;
- Microsoft.Office.Interop.Word.Application app = Globals.ThisAddIn.Application;
- Microsoft.Office.Interop.Word.Document doc1 = app.ActiveDocument;
- Microsoft.Office.Interop.Word.Selection wordSelection = app.ActiveWindow.Selection;
- Find fnd = doc1.Content.Find;
- fnd.ClearFormatting();
- fnd.Font.Hidden = 1;
- fnd.Replacement.ClearFormatting();
- fnd.Text = "";
- fnd.Replacement.Text = "";
- fnd.Forward = true;
- fnd.Wrap = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue;
- fnd.Format = true;
- fnd.set_Style("Instructions");
- ischeckforInstructions = fnd.Execute();
- fnd.ClearFormatting();
- fnd.Font.Hidden = 1;
- fnd.Replacement.ClearFormatting();
- fnd.Text = "";
- fnd.Replacement.Text = "";
- fnd.Forward = true;
- fnd.Wrap = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue;
- fnd.Format = true;
- fnd.set_Style("Guidance");
- ischeckforGuidence = fnd.Execute();
- if (ischeckforInstructions || ischeckforGuidence)
- {
- istoCheckInstructionsandGuidence = true;
- }
- }
- catch
- {
- }
- return istoCheckInstructionsandGuidence;
- }
Please anyone know the answer please reply me.
Thanks