Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-16-2020, 11:58 AM
thiagoafdoria thiagoafdoria is offline Turning pieces of regular text into comments and vice-versa Windows 10 Turning pieces of regular text into comments and vice-versa Office 2019
Novice
Turning pieces of regular text into comments and vice-versa
 
Join Date: Feb 2017
Posts: 18
thiagoafdoria is on a distinguished road
Default 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
Is it possible to adapt those macros in order to accomplish what I want regarding comments?

Thanks's!
Reply With Quote
 

Tags
comment balloons, macro



Similar Threads
Thread Thread Starter Forum Replies Last Post
Turning pieces of regular text into comments and vice-versa 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
Turning pieces of regular text into comments and vice-versa Trying to change Regular to Superscript and vice versa wardw Word VBA 6 07-07-2016 11:58 AM
Turning pieces of regular text into comments and vice-versa Sizing cells to pics (or even vice versa?) Guloluseus Excel 1 07-27-2014 11:24 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:29 AM.


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