#1
|
|||
|
|||
Insert Existing Comments at the End of Comment Selection Text
Hi All:
I'd like to know if there is a way to automatically insert existing comments into the end of existing relevant text selection. So for example, if my Word document contained the phrase: "I have a moon very far away." and I had selected the relevant text "a moon", and added a comment to the selection that said: "(this moon is very dear to me)", then when executed the VBA should produce and change the Word document (or create a new Word document) to now read "I have a moon (this moon is very dear to me) very far away." Obviously, the VBA code should repeat this action for all similar cases in the Word document. Could this be coded in VBA? Your help would be much appreciated. |
#2
|
|||
|
|||
Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey Dim lngIndex As Long Dim oRng As Range For lngIndex = ActiveDocument.Range.Comments.Count To 1 Step -1 Set oRng = ActiveDocument.Range.Comments(lngIndex).Reference oRng.InsertAfter " " & ActiveDocument.Range.Comments(lngIndex).Range.Text ActiveDocument.Range.Comments(lngIndex).Delete Next lngIndex lbl_Exit: Exit Sub End Sub |
#3
|
|||
|
|||
Hi Greg:
Thank you very much! It worked perfectly. Just curiosity if the following piece has any function: (I'm guessing not) " lbl_Exit: Exit Sub " |
#4
|
|||
|
|||
You guessed correctly. Just my style (or lack of).
|
Tags |
automatic insertion, existing comment, insert at the end |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to hide comments and comment indicators from OTHERS | Elena A | Excel | 0 | 12-03-2014 12:08 PM |
Selection of all Text for a specific page in word is spanning selection across pages | ramsgarla | Word VBA | 9 | 12-05-2012 03:23 AM |
How to insert a (balloon) comment and how to disable comment feature in Word2007? | pstein | Word | 2 | 03-31-2012 05:31 AM |
Show comment pane only on pages with comments? | symsvial | Word | 0 | 02-01-2011 07:06 AM |
using the insert voice comment feature with vista- help | farrellcollie | Word | 0 | 03-30-2009 12:56 AM |