We're sorry Aspose doesn't work properply without JavaScript enabled.

# Inserting text before and after text markered by comment

Hi,

We’re using aspose.words 5.1.1.0 to migrate from MS word automation. Currently we’re faced with following isssue: Is there any possibility to insert text(Run node) before and after text marked by comment?

For example with Interop we could do the following:

Range range = wordDocument.Comments[someIndex].Scope;
range.InsertBefore(“sometext1”);
range.InsertAfter(“sometext2”);


Thanks,

–Oleh

Hello

Thanks for your request. Yes, you can do it using Aspose.Words, but before you should update to at least to 8.2.0 version of Aspose.Words.

Document doc = new Document("C:\\Temp\\in.doc");
//Get CommentRangeStart and CommentRangeEnd
CommentRangeStart start = (CommentRangeStart)doc.GetChild(NodeType.CommentRangeStart, 0, true);
CommentRangeEnd end = (CommentRangeEnd)doc.GetChild(NodeType.CommentRangeEnd, 0, true);

//Insert text before CommentRangeStart
start.ParentNode.InsertBefore(new Run(doc, "This is text before comment range"), start);

//Insert text after CommentRangeStart
end.ParentNode.InsertAfter(new Run(doc, "This is text after comment range"), end);

doc.Save("C:\\Temp\\out.doc");


Best regards,

Save Edit

Hi Andrey,

Yesterday, I used the same approach with 9.4.0.0. However some comments are missing while searching by range.

Regards,
–Oleh

Hi Oleh,

Thank you for additional information. Could you please attach the document you are getting problem with? I will check it on my side and provide you more information.

Best regards,

Hi Oleh,

Thank you for additional information and sorry for the delay response. I cannot reproduce the problem with your document on my side. I use the latest version of Aspose.Words (9.8.0) for testing and the following code:

Document doc = new Document("C:\\Temp\\mietverlust_byDesigner.doc");

//Get CommentRangeStart nodes
Node[] starts = doc.GetChildNodes(NodeType.CommentRangeStart, true).ToArray();

foreach (CommentRangeStart start in starts)
{
Console.WriteLine(start.Id.ToString());
}


Best regards

Hi,

Could you please just check the document i’ve attached, there is two comments, seems like comment with ID = 0(I’ve opened it in document explorer), should have comment ranges, please confirm?

Hi

Thanks for your request. Comments in MS Word documents can have comment range and can do not have comment range. So if your document contains for example N comments it is not necessary that this document contains N comment ranges.

Best regards,

I think you misunderstood me, in document i’ve attached in previous post with two comments, it seems that comment with ID = 0 should have comment range start and comment range end. Could you please check that, or am I missing something?

Regards,

–Oleh

Hi Oleh,

Thank you for reporting this problem to us and for the additional information. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is fixed.

Best regards,

Hi Oleh,

Thank you for reporting this problem to us and for the additional information. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is fixed.

Best regards,

Hi,

Could you please provide me with some information if that bug was fixed?

–Oleh

Save Edit

Hi Oleh,

Thanks for your inquiry. Unfortunately, currently I cannot provide you any reliable estimate regarding this issue. We will be sure to inform you of any developments regarding this issue.

Best regards,

Hello,

Thanks,
–Oleh

Hi

Thanks for your request. Unfortunately, the issue is still unresolved. I asked the responsible developer to analyze the issue. Once we have more information we will share it with you.

I apologize for inconvenience.

Best regards,

Hello Alexey,

Could you please provide us with some information about the status of the issue and plans for fixing it. This is really critical for our release planning as well as maintenance of existing releases.

We are users of Aspose.Total license and now are in the process of making a decision to prolong it, however this bug can be a stopper to make a success decision.

Thanks,
Maksym Hukallo
Development Manager

Hi

Thanks for your request. Unfortunately, the issue is still unresolved. Please expect a reply from the responsible developer in few days. I am really sorry for inconvenience.

Best regards,

Hello Alexey,

Thank you for your response, however I wait already more than a week for the reply of the developer and can not wait indefinitely. So could you please provide me the status of my request or provide me with the escalation contact that can speed up the process.

Thanks,
Maksym Hukallo
Development Manager

Hi Eric,