Go Back   Tech Support Forum > Microsoft Support > Microsoft Office support

User Tag List

Macro for in-text comments in different colour

This is a discussion on Macro for in-text comments in different colour within the Microsoft Office support forums, part of the Tech Support Forum category. I want to insert revision text in draft documents in blue. I found a suggestion for a suitable macro: Dim


Closed Thread
 
Thread Tools Search this Thread
Old 11-05-2017, 03:15 PM   #1
Registered Member
 
Join Date: Nov 2011
Posts: 33
OS: Windows 10



I want to insert revision text in draft documents in blue.

I found a suggestion for a suitable macro:

Dim oRng As Range
Dim oChange As Revision
Dim bTrack As Boolean
bTrack =ActiveDocument.TrackRevisions
ActiveDocument.TrackRevisions = False
For Each oChange In ActiveDocumentRevisions
(indented) Set oRng = oChange.Range
(indented) oChange.Accept
(indented) oRng.Font.Color = wdColorBlue
Next oChange
ActiveDocument.TrackRevisions = bTrack

I assigned the macro to F11.

However, pressing F11 just prints the macro text instead of allowing me to type my revision in blue.

I have no idea what might be the cause of this failure.

With thanks for any pointers.
U-Ina
U-Ina is offline  
Sponsored Links
Advertisement
 
Old 11-06-2017, 01:22 PM   #2
Moderator
- Microsoft Support
Microsoft MVP
 
macropod's Avatar
 
Join Date: Apr 2008
Location: Australia
Posts: 2,527
OS: Win 7 (64-bit)



Quote:
Originally Posted by U-Ina View Post
I want to insert revision text in draft documents in blue.
So why not just change the 'track changes' insertion colour?

PS: When posting code, please use the code tags. They're on the 'Go Advanced' tab at the bottom of this screen. Without them, your code loses much of whatever structure it had. Simply typing '(indented)' when the indents should be only makes it even harder to read or work with your code.
__________________


Cheers,
Paul Edstein
(Fmr MS MVP - Word)
macropod is offline  
Old 11-06-2017, 02:35 PM   #3
Registered Member
 
Join Date: Nov 2011
Posts: 33
OS: Windows 10



OK, sorry about the unhelpful post.

I've attached a jpg file this time.

I don't want to change tracks for comments in the margin. Students report problems with that. So I want to insert comments in the text and show these by appearing in a different colour. I can do that by just changing the colour for the first letter of a comment. But doing this over and over again made me wonder if, instead, I could just tip F11 and Bob's your uncle.

So not an emergency. I am just looking for a bit of luxury from MS Office 2016.

U-Ina
Attached Thumbnails
Click image for larger version

Name:	Macro Colour change.jpg
Views:	8
Size:	126.0 KB
ID:	315193  
U-Ina is offline  
Sponsored Links
Advertisement
 
Old 11-06-2017, 02:43 PM   #4
Moderator
- Microsoft Support
Microsoft MVP
 
macropod's Avatar
 
Join Date: Apr 2008
Location: Australia
Posts: 2,527
OS: Win 7 (64-bit)



All you have done is record a macro that types the code for a macro into your document!!!!

Regardless, now you're referring to 'comments in the margin' which are not the same as tracked changes - though the type of change may be reported there and can easily be switched off without resorting to code.

It would be helpful if you were clear about what you're trying to achieve - changing the 'track changes' insertion colour - which I've already told you about - or moving comment text (which is entirely different) to the document body.
__________________


Cheers,
Paul Edstein
(Fmr MS MVP - Word)
macropod is offline  
Old 11-06-2017, 04:01 PM   #5
Registered Member
 
Join Date: Nov 2011
Posts: 33
OS: Windows 10



I am sorry to find you so impatient with a dunce like myself.

As I have already told you, with similar lack of success as your attempts to tell me what to do: Instead of using "Review" comments, I want to type into the existing text (that's a good idea). In that sentence, "that's a good idea" represents in bold what I would like to do in a different colour where the text I am commenting on is black on white.

However, you are welcome to tell me if that is still incomprehensible or just ignore me. It is, as I say just a bonus I am after.

With best wishes,
U-Ina
U-Ina is offline  
Old 11-06-2017, 04:22 PM   #6
Moderator
- Microsoft Support
Microsoft MVP
 
macropod's Avatar
 
Join Date: Apr 2008
Location: Australia
Posts: 2,527
OS: Win 7 (64-bit)



Since it seems we're dealing with comments, try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim i As Long, Rng As Range
With ActiveDocument
  For i = .Comments.Count To 1 Step -1
    With .Comments(i)
      Set Rng = .Reference
      Rng.Collapse wdCollapseEnd
      Rng.FormattedText = .Range.FormattedText
      With Rng
        .InsertBefore "["
        .InsertAfter "] "
        .HighlightColorIndex = wdPink
      End With
      .Delete
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
For PC macro installation & usage instructions, see: Installing Macros
For Mac macro installation & usage instructions, see: https://wordmvp.com/Mac/InstallMacro.html
__________________


Cheers,
Paul Edstein
(Fmr MS MVP - Word)
macropod is offline  
Old 11-08-2017, 09:36 AM   #7
Registered Member
 
Join Date: Nov 2011
Posts: 33
OS: Windows 10



Thank you for the script and the installation instructions. All went well until I tried to use the macro for inserting comments in a different colour of the given text.

I shall try again on another day.

Cheers,
U-Ina
U-Ina is offline  
Old 11-08-2017, 12:01 PM   #8
Moderator
- Microsoft Support
Microsoft MVP
 
macropod's Avatar
 
Join Date: Apr 2008
Location: Australia
Posts: 2,527
OS: Win 7 (64-bit)



The macro doesn't insert comments - it converts existing comments to in-line text. There is no way for Word to know that you're about to insert a comment unless you use the comment tool (which you could do for all your comments, then run the macro afterwards).
__________________


Cheers,
Paul Edstein
(Fmr MS MVP - Word)
macropod is offline  
Old 11-08-2017, 01:37 PM   #9
Registered Member
 
Join Date: Nov 2011
Posts: 33
OS: Windows 10



So my explanation of what I'd like to do was still incomprehensible.

However, I did find out a little about macros. It was worth the adventure. I also realised that changing colour by clicking the A at the top of the document works just as well. I only have to do it once for a whole document, since everything I might insert will have to be blue.

It was all very interesting.
Cheers,
U-Ina
U-Ina is offline  
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
Closed: Article Comments
https://www.gravatar.com/avatar.php?gravatar_id=942e9417aaa48c59a69018062d50c479&size=32&default=https://mediacdn.disqus.com/1307568157/images/noavatar32.png Ann Yacono ([email protected]) 64.240.127.17 ...
JohnthePilot Dead-Sea Scrolls 0 06-07-2011 02:09 AM
[SOLVED] help for excel macro to create pivottable [moved from Comments forum]
hi im hoping that someone can please help me to solve my little problem. i have got a macro which creates a pivottable.im looking to slightly adjust the pivottable with the macro code. currently the code is Sub Test() ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _...
wally32 Microsoft Office support 3 04-06-2011 10:38 AM
Macro to insert a range of text from one document to another
I need help in creating a macro in Word 2007 that will open a document that I created which has bookmarked paragraphs and then select one of these paragraphs and insert it into the document that is currently being worked on.
tammytutone Microsoft Office support 4 03-16-2011 01:31 PM
Burning error in audio blank using Nero 6
I have a burning error in audio blank using Nero 6. Below is my log, What is the problem ? Windows XP 5.1 IA32 WinAspi: - ahead WinASPI: File 'C:\Program Files\Ahead\Nero\Wnaspi32.dll': Ver=2.0.1.74, size=164112 bytes, created 10/26/2004 5:35:34 PM
zhong Windows XP Support 12 01-13-2011 11:22 PM

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is on
Smilies are on
[IMG] code is on
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Post a Question


» Site Navigation
 > FAQ
  > 10.0.0.2
Powered by vBadvanced CMPS v3.2.3


All times are GMT -7. The time now is 01:59 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
vBulletin Security provided by vBSecurity v2.2.2 (Pro) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.1.0 (Pro) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
Copyright 2001 - 2018, Tech Support Forum

Windows 10 - Windows 7 - Windows XP - Windows Vista - Trojan Removal - Spyware Removal - Virus Removal - Networking - Security - Top Web Hosts