Skip to content

Commit 46723e8

Browse files
committed
Addressed the feedback
1 parent 04ebb58 commit 46723e8

4 files changed

Lines changed: 8 additions & 0 deletions

File tree

Bookmarks/Add-bookmarks-to-all-paragraphs-and-retrieve-contents/.NET/Add-bookmarks-to-all-paragraphs-and-retrieve-contents/Add-bookmarks-to-all-paragraphs-and-retrieve-contents.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<None Update="Data\Input.docx">
1717
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
1818
</None>
19+
<None Update="Output\.gitkeep">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
1922
</ItemGroup>
2023

2124
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+


Bookmarks/Add-bookmarks-to-all-paragraphs-and-retrieve-contents/.NET/Add-bookmarks-to-all-paragraphs-and-retrieve-contents/Program.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ private static Dictionary<string, string> GetBookmarkContents(WordDocument docum
4444
{
4545
// Create a dictionary to store bookmark names and their contents
4646
Dictionary<string, string> bookmarkContents = new Dictionary<string, string>();
47+
int paragraphCount = 0;
4748
// Iterate through each bookmark
4849
foreach (Bookmark currentBookmark in document.Bookmarks)
4950
{
@@ -54,8 +55,11 @@ private static Dictionary<string, string> GetBookmarkContents(WordDocument docum
5455
WordDocument tempDoc = bookmarkNavigator.GetContent().GetAsWordDocument();
5556
// Get the text content and add it to the dictionary
5657
bookmarkContents.Add(currentBookmark.Name, tempDoc.GetText());
58+
// Save the Word document.
59+
tempDoc.Save(Path.GetFullPath("Output/Output_" + paragraphCount + ".docx"));
5760
// Close the temporary document.
5861
tempDoc.Close();
62+
paragraphCount++;
5963
}
6064
// Return the dictionary containing all bookmark contents
6165
return bookmarkContents;

0 commit comments

Comments
 (0)