![]() |
#1
|
|||
|
|||
![]()
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! |
Tags |
comment balloons, macro |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
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 |
![]() |
wardw | Word VBA | 6 | 07-07-2016 11:58 AM |
![]() |
Guloluseus | Excel | 1 | 07-27-2014 11:24 AM |