#1
|
|||
|
|||
Turning pieces of regular text into comments and vice-versa
Hi!
I don't know if it is possible, but I'd like to convert regular text into comments and to convert comments into regular text with macros. My idea is to use "###" to delimitate the text that should be converted into a comment. So I could have a paragraph in the middle of which there would be the following: ###This is a comment.###, and after I run the macro I would have in a balloon: This is a comment. (The "###" gets excluded). I already have two macros that accomplish almost the same regarding footnotes: 1. To transform text between "[!" and "!]" into footnotes, excluding those signs, "[!" and "!]" in the final result: Code:
Sub Demo() Application.ScreenUpdating = False Dim Rng As Range, FtNt As Footnote With ActiveDocument.Range With .Find .ClearFormatting .Replacement.ClearFormatting .Text = "\[\!*\!\]" .Replacement.Text = "" .Forward = True .Format = False .Wrap = wdFindStop .MatchWildcards = True .Execute End With Do While .Find.Found .Characters.First.Text = vbNullString .Characters.First.Text = vbNullString .Characters.Last.Text = vbNullString .Characters.Last.Text = vbNullString Set Rng = .Duplicate .Collapse wdCollapseStart Set FtNt = .Footnotes.Add(.Duplicate) Rng.Start = FtNt.Reference.End FtNt.Range.FormattedText = Rng.FormattedText Rng.Delete If .End = ActiveDocument.Range.End Then Exit Sub .Collapse wdCollapseEnd .Find.Execute Loop End With Application.ScreenUpdating = True End Sub 2. To turn footnotes into delimited fragments between "[!" and "!]" in the body of the text: Code:
Sub Demo() Application.ScreenUpdating = False Dim Rng As Range With ActiveDocument Do While .Footnotes.Count > 0 With .Footnotes(1) Set Rng = .Reference With Rng .Collapse wdCollapseStart .Text = "[!!]" .Start = .Start + 2 .Collapse wdCollapseStart End With Rng.FormattedText = .Range.FormattedText .Delete End With Loop End With Application.ScreenUpdating = True End Sub Thanks's! |
#2
|
||||
|
||||
It is relatively straightforward to do with code. Are you looking to have this macro toggle between inline 'tagged' comments to real comments and back again?
One difference between footnotes and comments is the 'anchor' in the text. A footnote anchor sits in an insertion point whereas a comment can have an insertion point but is usually attached to a range of text. Does it make sense to have your code anchor the comment to the from the start of the paragraph to where the opening tag began?
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Hi!
I'm sorry for the late reply. Yes, that's exactly it: I'm looking for macros that would enable me to toggle between inline "tagged" comments to real comments and back again. As for the anchor, my idea was to have just an insertion point, like the footnotes. I don't know if this is possible. If I had to attach the comment to a range of text, I'd prefer to attach it to the whole paragraph. Thank's! |
Tags |
comment balloons, macro |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Preserving formatting when turning footnotes into regular text | thiagoafdoria | Word VBA | 2 | 01-08-2020 01:25 PM |
Table captions changing to Figure captions and vice versa | alicatsmom | Word Tables | 0 | 06-11-2019 08:51 AM |
Turning off comments from individual author only | mikkelgivskov@gmail.com | Word | 1 | 08-27-2016 09:41 PM |
Trying to change Regular to Superscript and vice versa | wardw | Word VBA | 6 | 07-07-2016 11:58 AM |
Sizing cells to pics (or even vice versa?) | Guloluseus | Excel | 1 | 07-27-2014 11:24 AM |