Query on Word VBA - Comments.Range.Text extracting comments from a document and preserving formatting

oitbc

New Member
Joined
Mar 11, 2019
Messages
14
Hi All,

I've got a macro I have updated, based on some work from the past. It now sends the comments to Excel. The thing I noticed is that in using the Comments.Range.Text to get a copy of the comment, any formatting that was applied in the Comment is removed. This does not happen if I write the comment to a word table, only when I do it to a Excel cell.

For example:

If the comment says

"This isn't great, we need to repeat the newline and then make sure we display some numbered lists in it.

There is the newline above here

1. Item 1
2. Item 2"

it gets returned as a stream of

"This isn't great, we need to repeat the newline and then some numbered lists in it.There is the newlineItem 1Item 2"

when called by

VBA Code:
Celltofill = oDoc.Comments(n).Range.Text
and n is just a counter for a for loop

Any idea how to preserve the formatting?
 
Last edited:

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Sorry, I should say that when I use the following code

VBA Code:
Dim oTable As Table
For n = 1 To nCount
With oTable.Rows(n + 1)
'The text of the comment
.Cells(7).Range.Text = oDoc.Comments(n).Range.Text
in Word with a table then it does still remove the numbers, but does keep the newlines, so it looks like this in Word

"This isn't great, we need to repeat the newline and then make sure we display some numbered lists in it.

There is the newline above here

Item 1
Item 2"
 
Upvote 0

Forum statistics

Threads
1,223,650
Messages
6,173,594
Members
452,522
Latest member
saeedfiroozei

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top