Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 05-11-2019, 10:07 AM
Ramses505 Ramses505 is offline Windows 7 64bit Office 2010
Novice
 
Join Date: May 2019
Posts: 1
Ramses505 is on a distinguished road
Default Loop through Footnote Refernece Marks

I have some code that loops through the actual Footnotes that looks like this;


Code:
Sub Test_Format_Footnote()
Dim f As Footnote

For Each f In ActiveDocument.Footnotes
  With f.Range.Characters(1)
    If .Text = vbTab Or .Text = " " Then 'Use any other sensible detection logic here
      .Text = vbTab
    Else
      .InsertBefore "Look Here !"
    End If
  End With
Next
End Sub

How do I loop through the Footnote Reference Marks; the numbers in the text linking to the actual footnote ?


I would like to change the format of them on several ways - I would also like to know how to just loop through them for future reference.


Thanks
Reply With Quote
  #2  
Old 05-11-2019, 04:11 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,392
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

If you want to change the format of the footnote reference, modify the Footnote Reference Style. That way, you don't need any code to loop through them.

That said, if you have some other reason for looping through them, you might use code like:
Code:
Dim FtNt As Footnote
For Each FtNt In ActiveDocument.Footnotes
  With FtNt.Reference
    'Do stuff
  End With
Next
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 05-11-2019, 05:53 PM
eduzs eduzs is offline Windows 10 Office 2010 32bit
Competent Performer
 
Join Date: May 2017
Posts: 130
eduzs is on a distinguished road
Default

I don't know if you can change each footnote individually.
But, to format all footnotes at once references and text you can try (test, backup before) this:
(This code I use in one of my macros, so you need to adapt it to do what you need, if it's suitable for your needs)

Code:
Set doc = activedocument

doc.Footnotes(1).Range.text = doc.Footnotes(1).Range.text & "Hi" ' Add some text to the first footnote of the document
  
doc.Styles(wdStyleFootnoteReference).Font.Color = wdColorWhite ' Format the reference numbers

With doc.Styles(wdStyleFootnoteText) ' Format the main text itself
    .Font.Size = 16
    .ParagraphFormat.Alignment = wdAlignParagraphCenter
End With

doc.StoryRanges(wdFootnoteSeparatorStory).Delete ' The separator line (remove)
__________________
Backup your original file before doing any modification.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Space between footnote number and footnote text Sabya Word 6 07-29-2018 02:30 PM
Footnote spacing after last footnote Raffiki Word 3 04-22-2017 02:18 PM
How do I fix this unknown problem? Right-angle marks in corners - crop marks Quillo1234 Word 2 07-20-2016 02:24 AM
Problem with footnote numbering -- Two different footnote levels mdhg Word 7 05-19-2016 06:33 AM
No space between footnote number and footnote cgp1689 Word 6 10-13-2015 08:24 AM


All times are GMT -7. The time now is 11:12 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft