Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 15d7f97

Browse files
committedMar 13, 2025·
Working-with-SmartArts
1 parent ce52f36 commit 15d7f97

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed
 

‎SmartArts/Set-assistant-to-normal-node/.NET/Set-assistant-to-normal-node/Program.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@
55
using System.IO;
66

77
//Create a new Word document instance.
8-
WordDocument document = new WordDocument();
9-
//Add a new section to the document.
10-
IWSection section = document.AddSection();
11-
//Add a paragraph to the section.
12-
IWParagraph paragraph = section.AddParagraph();
8+
WordDocument wordDocument = new WordDocument();
9+
//Add one section and one paragraph to the document.
10+
wordDocument.EnsureMinimal();
1311
//Add a SmartArt to the paragraph at the specified size.
14-
WSmartArt smartArt = paragraph.AppendSmartArt(OfficeSmartArtType.OrganizationChart, 432, 252);
12+
WSmartArt smartArt = wordDocument.LastParagraph.AppendSmartArt(OfficeSmartArtType.OrganizationChart, 640, 426);
1513
//Traverse through all nodes of the SmartArt.
1614
foreach (IOfficeSmartArtNode node in smartArt.Nodes)
1715
{
18-
//Check if the node is assistant or not.
19-
if (node.IsAssistant)
20-
//Set the assistant node to false.
21-
node.IsAssistant = false;
16+
foreach (IOfficeSmartArtNode childNode in node.ChildNodes)
17+
{
18+
//Check if the node is assistant or not.
19+
if (childNode.IsAssistant)
20+
//Set the assistant node to false.
21+
childNode.IsAssistant = false;
22+
}
2223
}
2324
// Create a file stream to save the modified document.
2425
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))

0 commit comments

Comments
 (0)
Please sign in to comment.