|
5 | 5 | using System.IO;
|
6 | 6 |
|
7 | 7 | //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(); |
13 | 11 | //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); |
15 | 13 | //Traverse through all nodes of the SmartArt.
|
16 | 14 | foreach (IOfficeSmartArtNode node in smartArt.Nodes)
|
17 | 15 | {
|
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 | + } |
22 | 23 | }
|
23 | 24 | // Create a file stream to save the modified document.
|
24 | 25 | using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
|
|
0 commit comments