Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #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
  #2  
Old 01-16-2020, 01:54 PM
Guessed's Avatar
Guessed Guessed 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 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #3  
Old 01-21-2020, 09:19 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

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!
Reply With Quote
Reply

Tags
comment balloons, macro

Thread Tools
Display Modes


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 10:18 AM.


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