Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 10-30-2022, 12:21 PM
jpkell jpkell is offline Word macro for selecting text and putting it in footnotes Mac OS X Word macro for selecting text and putting it in footnotes Office 2016 for Mac
Novice
 
Join Date: Aug 2017
Posts: 4
jpkell is on a distinguished road
Default


Quote:
Originally Posted by RiSta View Post
I've already got docx. I'm not familiar with pandoc. Now I just need to move text in brackets to footnotes.
Sorry I can't help you with that, because I was the one that gmayor helped up above in this thread. Maybe they'll swoop in and help you. Good luck.
Reply With Quote
  #17  
Old 11-15-2023, 10:16 PM
fd110 fd110 is offline Word macro for selecting text and putting it in footnotes Windows 10 Word macro for selecting text and putting it in footnotes Office 2021
Novice
 
Join Date: Nov 2023
Posts: 7
fd110 is on a distinguished road
Default Great

Quote:
Originally Posted by gmayor View Post
My old friend Greg jumped in and took over the thread, but to address your concerns with my original macro try
Code:
Sub Macro1()
Dim oRng As Range
Dim strText As String
Dim i As Long
    Set oRng = ActiveDocument.Range
    i = 1
    With oRng.Find
        Do While .Execute(FindText:="\[\[(*)\]\]", _
                          MatchWildcards:=True)
            strText = Replace(oRng.Text, "[", "")
            strText = Replace(strText, "]", "")
            ActiveDocument.Footnotes.Add oRng, CStr(i), strText
            oRng.Text = ""
            i = i + 1
            oRng.Collapse 0
        Loop
    End With
lbl_Exit:
    Set oRng = Nothing
    Exit Sub
End Sub
If that doesn't work for you, post a sample from the document.
That is Great but I want to keep text formatting!!!
Is it possible to keep text formatting like Bold and font type & etc???
Reply With Quote
  #18  
Old 11-17-2023, 02:32 AM
fd110 fd110 is offline Word macro for selecting text and putting it in footnotes Windows 10 Word macro for selecting text and putting it in footnotes Office 2021
Novice
 
Join Date: Nov 2023
Posts: 7
fd110 is on a distinguished road
Default text formatting lost

Quote:
Originally Posted by gmayor View Post
My old friend Greg jumped in and took over the thread, but to address your concerns with my original macro try
Code:
Sub Macro1()
Dim oRng As Range
Dim strText As String
Dim i As Long
    Set oRng = ActiveDocument.Range
    i = 1
    With oRng.Find
        Do While .Execute(FindText:="\[\[(*)\]\]", _
                          MatchWildcards:=True)
            strText = Replace(oRng.Text, "[", "")
            strText = Replace(strText, "]", "")
            ActiveDocument.Footnotes.Add oRng, CStr(i), strText
            oRng.Text = ""
            i = i + 1
            oRng.Collapse 0
        Loop
    End With
lbl_Exit:
    Set oRng = Nothing
    Exit Sub
End Sub
If that doesn't work for you, post a sample from the document.

text formatting like bold & etc lost!
Reply With Quote
  #19  
Old 11-17-2023, 04:00 PM
Guessed's Avatar
Guessed Guessed is offline Word macro for selecting text and putting it in footnotes Windows 10 Word macro for selecting text and putting it in footnotes Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
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

If the text formatting is coming from the underlying paragraph style then you won't get it but local character formatting will be preserved by this modification.
Code:
Sub Macro1()
  Dim oRng As Range, oFN As Footnote, rngInner As Range
  Set oRng = ActiveDocument.Range
  With oRng.Find
    Do While .Execute(FindText:="\[\[(*)\]\]", MatchWildcards:=True)
      Set oFN = ActiveDocument.Footnotes.Add(oRng, , oRng.Text)
      Set rngInner = oRng.Duplicate
      rngInner.MoveStart Unit:=wdCharacter, Count:=2
      rngInner.MoveEnd Unit:=wdCharacter, Count:=-2
      oFN.Range.FormattedText = rngInner.FormattedText
      oRng.Text = ""
    Loop
  End With
lbl_Exit:
  Set oRng = Nothing
  Set rngInner = Nothing
  Exit Sub
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #20  
Old 11-18-2023, 01:19 PM
fd110 fd110 is offline Word macro for selecting text and putting it in footnotes Windows 10 Word macro for selecting text and putting it in footnotes Office 2021
Novice
 
Join Date: Nov 2023
Posts: 7
fd110 is on a distinguished road
Default perfect

thanks a lot
Reply With Quote
  #21  
Old 03-06-2024, 08:07 AM
fd110 fd110 is offline Word macro for selecting text and putting it in footnotes Windows 10 Word macro for selecting text and putting it in footnotes Office 2021
Novice
 
Join Date: Nov 2023
Posts: 7
fd110 is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
If the text formatting is coming from the underlying paragraph style then you won't get it but local character formatting will be preserved by this modification.
Code:
Sub Macro1()
  Dim oRng As Range, oFN As Footnote, rngInner As Range
  Set oRng = ActiveDocument.Range
  With oRng.Find
    Do While .Execute(FindText:="\[\[(*)\]\]", MatchWildcards:=True)
      Set oFN = ActiveDocument.Footnotes.Add(oRng, , oRng.Text)
      Set rngInner = oRng.Duplicate
      rngInner.MoveStart Unit:=wdCharacter, Count:=2
      rngInner.MoveEnd Unit:=wdCharacter, Count:=-2
      oFN.Range.FormattedText = rngInner.FormattedText
      oRng.Text = ""
    Loop
  End With
lbl_Exit:
  Set oRng = Nothing
  Set rngInner = Nothing
  Exit Sub
End Sub


Thank you very much, I have another problem.
I have a number of comments in the text, which will be deleted by moving the text to the footnote.
Is there a way to move those comments, for example, to the footnote number in the main text and not delete them?
Reply With Quote
Reply

Tags
footnotes, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word macro for selecting text and putting it in footnotes Word 2013 does not search text in footnotes unless I first click in a footnote amz Word 1 11-18-2015 01:56 PM
Word macro for selecting text and putting it in footnotes word 2007 - footnotes and text box glggluig Word 1 08-10-2014 04:09 AM
Putting text in color shapes dianabanana Word 1 04-07-2014 08:07 PM
Word macro for selecting text and putting it in footnotes Putting text to Excel Leandro Office 2 03-01-2012 11:51 PM
Selecting the macro document lars Word VBA 0 08-19-2010 06:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:30 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