I have an HTML doc which needs to be opened in MS Word. It has header text with specific fonts/color after every 2-3 pages (lets say 13.5pt & color code is #ff11ff) & I wish to find the page number in which header text is present.
What HTML tags can come handy while detecting the presence of a particular text in an MS Word environment? As far as I know, we can detect text using the find method but I am not aware if there is any method to search to look for particular ‘FONT/Font Color’,
I need this to create an index page which will have the name of the header & page number on which they were found. So it goes like:
- Find a particular font sized text.
- Get a current page number of that page.
Update:
Seems like i have to iterate on every text of doc & check it’s font & then do something like
Microsoft.Office.Interop.Word._Application word = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word._Document document;
while (word.Selection.Find.Execute(ref findStr, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull))
{
float fontSize = word.Selection.Font.Size;
if (fontSize == 13.5)
{
Range rng = word.Selection.Range;
int pageNp = (int)rng.get_Information(WdInformation.wdActiveEndPageNumber);
}
}
You have a few different approaches you can take; as if you ignore Microsoft Word. jQuery can easily pinpoint specific Html or Stylesheet tags.
If your trying to write a simple C# application to identify those two request. You could utilize Regular Expressions; they are quite powerful and are specifically designed to filter and parse through large amounts of data.
Due to the lack of information in your question, I can’t point you in any further but I do hope that helps. You can find additional information on Regular Expressions here: That cheat sheet should point you into several capabilities.
The approach I would take:
Obviously that is a very general approach. But hopefully that points you in a good direction. I’m not familiar with your task or goals; so this may hit the nail on the head or not.
So I apologize if it is vague, but we don’t know your project so it makes responses difficult. If you don’t mind me asking; could you update your question with your current iteration or approach? So we can analyze the code and maybe your desired goal?