Skip to content

Commit 99cb04c

Browse files
committed
add sample for how to reply to a comment
1 parent 3132350 commit 99cb04c

File tree

8 files changed

+152
-27
lines changed

8 files changed

+152
-27
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
3+
api_name:
4+
- Microsoft.Office.DocumentFormat.OpenXML.Packaging
5+
api_type:
6+
- schema
7+
ms.assetid: 9774217d-1f71-494a-9ab9-a711661f8e83
8+
title: 'How to: Reply to a comment in a presentation'
9+
ms.suite: office
10+
11+
ms.author: o365devx
12+
author: o365devx
13+
ms.topic: conceptual
14+
ms.date: 08/12/2025
15+
ms.localizationpriority: medium
16+
---
17+
18+
# Reply to a comment in a presentation
19+
20+
This topic shows how to use the classes in the Open XML SDK for
21+
Office to reply to existing comments in a presentation
22+
programmatically.
23+
24+
25+
[!include[Structure](../includes/presentation/structure.md)]
26+
27+
[!include[description of a comment](../includes/presentation/modern-comment-description.md)]
28+
29+
## How the Sample Code Works
30+
31+
The sample code opens the presentation document in the using statement. Then it gets or creates the CommentAuthorsPart, and verifies that there is an existing comment authors part. If there is not, it adds one.
32+
33+
### [C#](#tab/cs-1)
34+
[!code-csharp[](../../samples/presentation/reply_to_comment/cs/Program.cs#snippet1)]
35+
36+
### [Visual Basic](#tab/vb-1)
37+
[!code-vb[](../../samples/presentation/reply_to_comment/vb/Program.vb#snippet1)]
38+
***
39+
40+
Next the code determines if the author that is passed in is on the list of existing authors; if so, it assigns the existing author ID. If not, it adds a new author to the list of authors and assigns an author ID and the parameter values.
41+
42+
### [C#](#tab/cs-2)
43+
[!code-csharp[](../../samples/presentation/reply_to_comment/cs/Program.cs#snippet2)]
44+
45+
### [Visual Basic](#tab/vb-2)
46+
[!code-vb[](../../samples/presentation/reply_to_comment/vb/Program.vb#snippet2)]
47+
***
48+
49+
Next the code gets the first slide part and verifies that it exists, then checks if there are any comment parts associated with the slide.
50+
51+
### [C#](#tab/cs-3)
52+
[!code-csharp[](../../samples/presentation/reply_to_comment/cs/Program.cs#snippet3)]
53+
54+
### [Visual Basic](#tab/vb-3)
55+
[!code-vb[](../../samples/presentation/reply_to_comment/vb/Program.vb#snippet3)]
56+
***
57+
58+
The code then retrieves the comment list and then iterates through each comment in the comment list, displays the comment text to the user, and prompts whether they want to reply to each comment.
59+
60+
### [C#](#tab/cs-5)
61+
[!code-csharp[](../../samples/presentation/reply_to_comment/cs/Program.cs#snippet4)]
62+
63+
### [Visual Basic](#tab/vb-5)
64+
[!code-vb[](../../samples/presentation/reply_to_comment/vb/Program.vb#snippet4)]
65+
***
66+
67+
When the user chooses to reply to a comment, the code prompts for the reply text, then gets or creates a `CommentReplyList` for the comment and adds the new reply with the appropriate author information and timestamp.
68+
69+
### [C#](#tab/cs-6)
70+
[!code-csharp[](../../samples/presentation/reply_to_comment/cs/Program.cs#snippet5)]
71+
72+
### [Visual Basic](#tab/vb-6)
73+
[!code-vb[](../../samples/presentation/reply_to_comment/vb/Program.vb#snippet5)]
74+
***
75+
76+
## Sample Code
77+
78+
Following is the complete code sample showing how to reply to existing comments
79+
in a presentation slide with modern PowerPoint comments.
80+
81+
### [C#](#tab/cs)
82+
[!code-csharp[](../../samples/presentation/reply_to_comment/cs/Program.cs#snippet0)]
83+
84+
### [Visual Basic](#tab/vb)
85+
[!code-vb[](../../samples/presentation/reply_to_comment/vb/Program.vb#snippet0)]
86+
***
87+
88+
## See also
89+
90+
91+
- [Open XML SDK class library reference](/office/open-xml/open-xml-sdk)

docs/presentation/overview.md

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.suite: office
1111
ms.author: o365devx
1212
author: o365devx
1313
ms.topic: conceptual
14-
ms.date: 11/01/2017
14+
ms.date: 08/12/2025
1515
ms.localizationpriority: high
1616
---
1717
# Presentations
@@ -20,60 +20,62 @@ This section provides how-to topics for working with presentation documents usin
2020

2121
## In this section
2222

23-
- [Structure of a PresentationML document](structure-of-a-presentationml-document.md)
24-
23+
- [Structure of a PresentationML document](structure-of-a-presentationml-document.md)
24+
2525

2626
- [Add an audio file to a slide in a presentation](how-to-add-an-audio-to-a-slide-in-a-presentation.md)
2727

28-
- [Add a comment to a slide in a presentation](how-to-add-a-comment-to-a-slide-in-a-presentation.md)
28+
- [Add a comment to a slide in a presentation](how-to-add-a-comment-to-a-slide-in-a-presentation.md)
29+
30+
- [Reply to a comment in a presentation](how-to-reply-to-a-comment-in-a-presentation.md)
2931

30-
- [Apply a theme to a presentation](how-to-apply-a-theme-to-a-presentation.md)
32+
- [Apply a theme to a presentation](how-to-apply-a-theme-to-a-presentation.md)
3133

32-
- [Change the fill color of a shape in a presentation](how-to-change-the-fill-color-of-a-shape-in-a-presentation.md)
34+
- [Change the fill color of a shape in a presentation](how-to-change-the-fill-color-of-a-shape-in-a-presentation.md)
3335

34-
- [Create a presentation document by providing a file name](how-to-create-a-presentation-document-by-providing-a-file-name.md)
36+
- [Create a presentation document by providing a file name](how-to-create-a-presentation-document-by-providing-a-file-name.md)
3537

36-
- [Delete all the comments by an author from all the slides in a presentation](how-to-delete-all-the-comments-by-an-author-from-all-the-slides-in-a-presentation.md)
38+
- [Delete all the comments by an author from all the slides in a presentation](how-to-delete-all-the-comments-by-an-author-from-all-the-slides-in-a-presentation.md)
3739

38-
- [Delete a slide from a presentation](how-to-delete-a-slide-from-a-presentation.md)
40+
- [Delete a slide from a presentation](how-to-delete-a-slide-from-a-presentation.md)
3941

40-
- [Get all the external hyperlinks in a presentation](how-to-get-all-the-external-hyperlinks-in-a-presentation.md)
42+
- [Get all the external hyperlinks in a presentation](how-to-get-all-the-external-hyperlinks-in-a-presentation.md)
4143

42-
- [Get all the text in a slide in a presentation](how-to-get-all-the-text-in-a-slide-in-a-presentation.md)
44+
- [Get all the text in a slide in a presentation](how-to-get-all-the-text-in-a-slide-in-a-presentation.md)
4345

44-
- [Get all the text in all slides in a presentation](how-to-get-all-the-text-in-all-slides-in-a-presentation.md)
46+
- [Get all the text in all slides in a presentation](how-to-get-all-the-text-in-all-slides-in-a-presentation.md)
4547

4648
- [Get the titles of all the slides in a presentation](how-to-get-the-titles-of-all-the-slides-in-a-presentation.md)
4749

48-
- [Insert a new slide into a presentation](how-to-insert-a-new-slide-into-a-presentation.md)
50+
- [Insert a new slide into a presentation](how-to-insert-a-new-slide-into-a-presentation.md)
4951

50-
- [Move a slide to a new position in a presentation](how-to-move-a-slide-to-a-new-position-in-a-presentation.md)
52+
- [Move a slide to a new position in a presentation](how-to-move-a-slide-to-a-new-position-in-a-presentation.md)
5153

52-
- [Move a paragraph from one presentation to another](how-to-move-a-paragraph-from-one-presentation-to-another.md)
54+
- [Move a paragraph from one presentation to another](how-to-move-a-paragraph-from-one-presentation-to-another.md)
5355

54-
- [Open a presentation document for read-only access](how-to-open-a-presentation-document-for-read-only-access.md)
56+
- [Open a presentation document for read-only access](how-to-open-a-presentation-document-for-read-only-access.md)
5557

5658
- [Retrieve the number of slides in a presentation document](how-to-retrieve-the-number-of-slides-in-a-presentation-document.md)
57-
59+
5860
- [Add a transition to a slides in a presentation](how-to-add-transitions-between-slides-in-a-presentation.md)
5961

60-
- [Working with animation](working-with-animation.md)
62+
- [Working with animation](working-with-animation.md)
6163

62-
- [Working with comments](working-with-comments.md)
64+
- [Working with comments](working-with-comments.md)
6365

64-
- [Working with handout master slides](working-with-handout-master-slides.md)
66+
- [Working with handout master slides](working-with-handout-master-slides.md)
6567

66-
- [Working with notes slides](working-with-notes-slides.md)
68+
- [Working with notes slides](working-with-notes-slides.md)
6769

68-
- [Working with presentations](working-with-presentations.md)
70+
- [Working with presentations](working-with-presentations.md)
6971

70-
- [Working with presentation slides](working-with-presentation-slides.md)
72+
- [Working with presentation slides](working-with-presentation-slides.md)
7173

72-
- [Working with slide layouts](working-with-slide-layouts.md)
74+
- [Working with slide layouts](working-with-slide-layouts.md)
7375

74-
- [Working with slide masters](working-with-slide-masters.md)
76+
- [Working with slide masters](working-with-slide-masters.md)
7577

7678

77-
## Related sections
79+
## Related sections
7880

79-
- [Getting started with the Open XML SDK for Office](../getting-started.md)
81+
- [Getting started with the Open XML SDK for Office](../getting-started.md)

docs/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
href: presentation/how-to-add-an-audio-to-a-slide-in-a-presentation.md
4949
- name: Add a comment to a slide in a presentation
5050
href: presentation/how-to-add-a-comment-to-a-slide-in-a-presentation.md
51+
- name: Reply to a comment in a presentation
52+
href: presentation/how-to-reply-to-a-comment-in-a-presentation.md
5153
- name: Add a video to a slide in a presentation
5254
href: presentation/how-to-add-a-video-to-a-slide-in-a-presentation.md
5355
- name: Apply a theme to a presentation
11.3 KB
Binary file not shown.
Binary file not shown.
12.7 KB
Binary file not shown.
Binary file not shown.

samples/samples.sln

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "replace_text_with_sax_cs",
336336
EndProject
337337
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "replace_text_with_sax_vb", "word\replace_text_with_sax\vb\replace_text_with_sax_vb.vbproj", "{6EB91F44-EC13-5354-0450-9A2687C3B169}"
338338
EndProject
339+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "reply_to_comment_cs", "presentation\reply_to_comment\cs\reply_to_comment_cs.csproj", "{DD6D10D2-709D-48EC-81C4-7FEC05E7FF37}"
340+
EndProject
341+
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "reply_to_comment_vb", "presentation\reply_to_comment\vb\reply_to_comment_vb.vbproj", "{6A4A278C-2304-47C6-9D7B-4C8D046FE719}"
342+
EndProject
339343
Global
340344
GlobalSection(SolutionConfigurationPlatforms) = preSolution
341345
Debug|Any CPU = Debug|Any CPU
@@ -2278,6 +2282,30 @@ Global
22782282
{6EB91F44-EC13-5354-0450-9A2687C3B169}.Release|x64.Build.0 = Release|Any CPU
22792283
{6EB91F44-EC13-5354-0450-9A2687C3B169}.Release|x86.ActiveCfg = Release|Any CPU
22802284
{6EB91F44-EC13-5354-0450-9A2687C3B169}.Release|x86.Build.0 = Release|Any CPU
2285+
{DD6D10D2-709D-48EC-81C4-7FEC05E7FF37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2286+
{DD6D10D2-709D-48EC-81C4-7FEC05E7FF37}.Debug|Any CPU.Build.0 = Debug|Any CPU
2287+
{DD6D10D2-709D-48EC-81C4-7FEC05E7FF37}.Debug|x64.ActiveCfg = Debug|Any CPU
2288+
{DD6D10D2-709D-48EC-81C4-7FEC05E7FF37}.Debug|x64.Build.0 = Debug|Any CPU
2289+
{DD6D10D2-709D-48EC-81C4-7FEC05E7FF37}.Debug|x86.ActiveCfg = Debug|Any CPU
2290+
{DD6D10D2-709D-48EC-81C4-7FEC05E7FF37}.Debug|x86.Build.0 = Debug|Any CPU
2291+
{DD6D10D2-709D-48EC-81C4-7FEC05E7FF37}.Release|Any CPU.ActiveCfg = Release|Any CPU
2292+
{DD6D10D2-709D-48EC-81C4-7FEC05E7FF37}.Release|Any CPU.Build.0 = Release|Any CPU
2293+
{DD6D10D2-709D-48EC-81C4-7FEC05E7FF37}.Release|x64.ActiveCfg = Release|Any CPU
2294+
{DD6D10D2-709D-48EC-81C4-7FEC05E7FF37}.Release|x64.Build.0 = Release|Any CPU
2295+
{DD6D10D2-709D-48EC-81C4-7FEC05E7FF37}.Release|x86.ActiveCfg = Release|Any CPU
2296+
{DD6D10D2-709D-48EC-81C4-7FEC05E7FF37}.Release|x86.Build.0 = Release|Any CPU
2297+
{6A4A278C-2304-47C6-9D7B-4C8D046FE719}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2298+
{6A4A278C-2304-47C6-9D7B-4C8D046FE719}.Debug|Any CPU.Build.0 = Debug|Any CPU
2299+
{6A4A278C-2304-47C6-9D7B-4C8D046FE719}.Debug|x64.ActiveCfg = Debug|Any CPU
2300+
{6A4A278C-2304-47C6-9D7B-4C8D046FE719}.Debug|x64.Build.0 = Debug|Any CPU
2301+
{6A4A278C-2304-47C6-9D7B-4C8D046FE719}.Debug|x86.ActiveCfg = Debug|Any CPU
2302+
{6A4A278C-2304-47C6-9D7B-4C8D046FE719}.Debug|x86.Build.0 = Debug|Any CPU
2303+
{6A4A278C-2304-47C6-9D7B-4C8D046FE719}.Release|Any CPU.ActiveCfg = Release|Any CPU
2304+
{6A4A278C-2304-47C6-9D7B-4C8D046FE719}.Release|Any CPU.Build.0 = Release|Any CPU
2305+
{6A4A278C-2304-47C6-9D7B-4C8D046FE719}.Release|x64.ActiveCfg = Release|Any CPU
2306+
{6A4A278C-2304-47C6-9D7B-4C8D046FE719}.Release|x64.Build.0 = Release|Any CPU
2307+
{6A4A278C-2304-47C6-9D7B-4C8D046FE719}.Release|x86.ActiveCfg = Release|Any CPU
2308+
{6A4A278C-2304-47C6-9D7B-4C8D046FE719}.Release|x86.Build.0 = Release|Any CPU
22812309
EndGlobalSection
22822310
GlobalSection(SolutionProperties) = preSolution
22832311
HideSolutionNode = FALSE
@@ -2443,6 +2471,8 @@ Global
24432471
{2DD90EFB-7F2A-497B-A0F4-EE5F62A49BA4} = {7ACDC26B-C774-4004-8553-87E862D1E71F}
24442472
{4C514047-64B5-1383-4564-B827B846A6A7} = {D207D3D7-FD4D-4FD4-A7D0-79A82086FB6F}
24452473
{6EB91F44-EC13-5354-0450-9A2687C3B169} = {D207D3D7-FD4D-4FD4-A7D0-79A82086FB6F}
2474+
{DD6D10D2-709D-48EC-81C4-7FEC05E7FF37} = {CDB9D4A6-7A7A-4CDF-A7A3-4F17F5F1602D}
2475+
{6A4A278C-2304-47C6-9D7B-4C8D046FE719} = {CDB9D4A6-7A7A-4CDF-A7A3-4F17F5F1602D}
24462476
EndGlobalSection
24472477
GlobalSection(ExtensibilityGlobals) = postSolution
24482478
SolutionGuid = {721B3030-08D7-4412-9087-D1CFBB3F5046}

0 commit comments

Comments
 (0)