Aspose::Words::Comment::Comment constructor

Comment::Comment(const System::SharedPtr<Aspose::Words::DocumentBase>&) constructor

Initializes a new instance of the Comment class.

Aspose::Words::Comment::Comment(const System::SharedPtr<Aspose::Words::DocumentBase> &doc)
ParameterTypeDescription
docconst System::SharedPtr<Aspose::Words::DocumentBase>&The owner document.

Remarks

When Comment is created, it belongs to the specified document, but is not yet part of the document and ParentNode is null.

To append Comment to the document use InsertAfter1() or InsertBefore1() on the paragraph where you want the comment inserted.

After creating a comment, don’t forget to set its Author, Initial and DateTime properties.

See Also

Comment::Comment(const System::SharedPtr<Aspose::Words::DocumentBase>&, const System::String&, const System::String&, System::DateTime) constructor

Initializes a new instance of the Comment class.

Aspose::Words::Comment::Comment(const System::SharedPtr<Aspose::Words::DocumentBase> &doc, const System::String &author, const System::String &initial, System::DateTime dateTime)
ParameterTypeDescription
docconst System::SharedPtr<Aspose::Words::DocumentBase>&The owner document.
authorconst System::String&The author name for the comment. Cannot be null.
initialconst System::String&The author initials for the comment. Cannot be null.
dateTimeSystem::DateTimeThe date and time for the comment.

Examples

Shows how to add a comment to a paragraph.

auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
builder->Write(u"Hello world!");

auto comment = System::MakeObject<Aspose::Words::Comment>(doc, u"John Doe", u"JD", System::DateTime::get_Today());
builder->get_CurrentParagraph()->AppendChild<System::SharedPtr<Aspose::Words::Comment>>(comment);
builder->MoveTo(comment->AppendChild<System::SharedPtr<Aspose::Words::Paragraph>>(System::MakeObject<Aspose::Words::Paragraph>(doc)));
builder->Write(u"Comment text.");

ASSERT_EQ(System::DateTime::get_Today(), comment->get_DateTime());

// In Microsoft Word, we can right-click this comment in the document body to edit it, or reply to it.
doc->Save(get_ArtifactsDir() + u"InlineStory.AddComment.docx");

See Also