How can I check if a specific word in a Word document is bold? I’ve managed to find the Bold property, but it only returns true on a paragraph if at least one of the letters in the paragraph is bold. I need to be able to check if the whole paragraph is bold.
Here’s my code so far, using the Word.Interop library.
// Open a doc file.
var application = new Application();
var document = application.Documents.Open(path);
// Loop through all words in the document.
foreach (Paragraph paragraph in document.Paragraphs)
{
Console.WriteLine(paragraph.Range.Text + "");
Console.WriteLine();
if (paragraph.Range.Font.Bold > 0)
{
Console.WriteLine("Is bold");
Console.Read();
}
}
// Close word.
application.Quit();
you’d need to loop through each word or each letter (depending on precision needed) and check if it’s bold as explained here: https://stackoverflow.com/questions/5879880/…