Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@ static void Main(string[] args)
document.GetText();
//Find all paragraphs with the style 'Heading 3' in the Word document.
List<Entity> headingParagraphs = document.FindAllItemsByProperty(EntityType.Paragraph, "StyleName", "Heading 3");
if (headingParagraphs.Count == 0)
if (headingParagraphs == null)
Console.WriteLine("No paragraphs with the style 'Heading 3' found.");
else
{
foreach (Entity paragraph in headingParagraphs)
{
//Get the string that represents the appearance of list value of the paragraph.
if (paragraph is WParagraph)
Console.WriteLine((paragraph as WParagraph).ListString);
else
Console.WriteLine("The entity is not a WParagraph.");
foreach (Entity entity in headingParagraphs)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

headingParagraphs may be null. SO, check and change if

{
WParagraph paragraph = entity as WParagraph;
//Get the heading number and the heading text together.
Console.WriteLine(paragraph.ListString + paragraph.Text);
}
}
//Pauses the console to display the output.
Expand Down
Loading