Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-30-2015, 04:10 PM
mercadogs mercadogs is offline Insert Existing Comments at the End of Comment Selection Text Windows 7 64bit Insert Existing Comments at the End of Comment Selection Text Office 2010 32bit
Novice
Insert Existing Comments at the End of Comment Selection Text
 
Join Date: Dec 2015
Posts: 6
mercadogs is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 12-30-2015, 05:03 PM
gmaxey gmaxey is offline Insert Existing Comments at the End of Comment Selection Text Windows 7 32bit Insert Existing Comments at the End of Comment Selection Text Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 12-30-2015, 06:50 PM
mercadogs mercadogs is offline Insert Existing Comments at the End of Comment Selection Text Windows 7 64bit Insert Existing Comments at the End of Comment Selection Text Office 2010 32bit
Novice
Insert Existing Comments at the End of Comment Selection Text
 
Join Date: Dec 2015
Posts: 6
mercadogs is on a distinguished road
Default

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

"
Reply With Quote
  #4  
Old 12-31-2015, 03:49 AM
gmaxey gmaxey is offline Insert Existing Comments at the End of Comment Selection Text Windows 7 32bit Insert Existing Comments at the End of Comment Selection Text Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

You guessed correctly. Just my style (or lack of).
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply

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
Insert Existing Comments at the End of Comment Selection Text 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
Insert Existing Comments at the End of Comment Selection Text 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

Other Forums: Access Forums

All times are GMT -7. The time now is 02:04 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft