![]() |
#1
|
|||
|
|||
![]()
I want to insert a letter 'a' after the reference number in the footnote area, a number that is always followed by a space. I use the code here below, but the result I get is not |1a| but |1 a|.
Can someone help? Thanks! With ftNote.Range .InsertBefore supLetter 'i.e. the letter a .Characters(1).Font.Superscript = True End With |
#2
|
|||
|
|||
![]()
RobiNew
Your code doesn't do anything. Inserting the "a" after the reference number as you request is at best a mirage. It will not affect the numbering of the footnote in the document body. In any case: Code:
Sub ScratchMacro() 'A basic Word Macro coded by Gregory K. Maxey Dim ftNote As Footnote Dim supLetter As String supLetter = "a" Set ftNote = ActiveDocument.Footnotes(1) With ftNote .Range.Characters.First.Previous.Delete .Range = supLetter & " " & .Range .Range.Characters.First.Font.Superscript = True End With lbl_Exit: Exit Sub End Sub |
#3
|
|||
|
|||
![]()
Thank you, gmaxey! But my code works, no mirage. The only trouble is that it inserts the 'a' after instead of before the space: |1 a| instead of |1a |. The numbering of the footnotes in the document body has been dealt with before with adequate code.
I cannot adopt your code, because it deletes the reference number. My code doesn't, neither in the main document nor in the footnote area. |
#4
|
|||
|
|||
![]()
RobiNew,
We will have to agree to disagree. The code you posted doesn't work to do anything. Start with a document with 1 footnote. Code:
Sub ScratchMacro() 'Here is your code. If you try to run it, you will see it does nothing but error With ftNote.Range .InsertBefore supLetter 'i.e. the letter a .Characters(1).Font.Superscript = True End With lbl_Exit: Exit Sub End Sub Sub ScratchMacro2() 'Here is your code modified with variables declared and defined. 'No erorrs and doing what you decribed. Dim ftNote As Footnote Dim supLetter As String Set ftNote = ActiveDocument.Footnotes(1) supLetter = "a" With ftNote.Range .InsertBefore supLetter 'i.e. the letter a .Characters(1).Font.Superscript = True End With 'As you see, this does nothing to the actual reference in the document body. lbl_Exit: Exit Sub End Sub Sub ScratchMacro3() 'A basic Word Macro coded by Gregory K. Maxey 'This is my code. It gives the illusion that the reference number has been changed from 1 to 1a, but 'has no affect on the actual reference number in the document body. Dim ftNote As Footnote Dim supLetter As String supLetter = "a" Set ftNote = ActiveDocument.Footnotes(1) With ftNote .Range.Characters.First.Previous.Delete .Range = supLetter & " " & .Range .Range.Characters.First.Font.Superscript = True End With lbl_Exit: Exit Sub End Sub |
#5
|
|||
|
|||
![]()
Thank you, gmaxey! As I wrote before my code works all right in the context of a macro. I have no problems with the reference numbers in the main document. All I need is a code that will ADD the letter 'a' after the reference number in the footnote area.
Perhaps someone will modify my code so as to obtain '1a ' instead of the wrong '1 a'. Here is again my wrong code: With ftNote.Range .InsertBefore supLetter 'i.e. the letter a .Characters(1).Font.Superscript = True End With |
#6
|
|||
|
|||
![]()
Hi, RobiNew! If I understand your request correctly, try the following:
Code:
With ftNote.range ActiveDocument.range(.start - 1, .End).InsertBefore supLetter End With Last edited by vivka; 08-11-2025 at 02:43 PM. |
#7
|
|||
|
|||
![]()
I have already provided you the answer twice. If you can't post functional code, why should anyone else. The code I have given you acted on footnote 1. If you want an "a" after all footnotes you can use:
Code:
Sub ScratchMacro3() 'A basic Word Macro coded by Gregory K. Maxey Dim ftNote As Footnote Dim supLetter As String supLetter = "a" For Each ftNote In ActiveDocument.Footnotes With ftNote .Range.Characters.First.Previous.Delete .Range = supLetter & " " & .Range .Range.Characters.First.Font.Superscript = True End With Next lbl_Exit: Exit Sub End Sub |
#8
|
|||
|
|||
![]()
Thank you Vivka! Unfortunately your code doesn't work in my macro. Please note that I need an "a" after all footnote numbers in the footnote area. I need a modification of my line '.Characters(1).Font.Superscript = True' to obtain '1a ' instead of '1 a'. All the best!
Thank you gmaxey! As you certainly know by now I'm not an expert. If you prefer not to modify my code (which works all right for '1 a', but not for '1a '), then please suggest a macro that does the job in both the main document and the footnote area, because that is what my macro does (correctly in the main document: '1a'). All the best! |
#9
|
|||
|
|||
![]()
As I have told you twice before, your macro does nothing!! If you want to send the code that does do something then perhaps I could assist you further. However, if you want to continue insisting that your non-functional code works then I will bow out.
|
#10
|
|||
|
|||
![]()
Hi again, RobiNew! Greg's code works without a hitch (at least for me). The code inserts a superscripted 'a' after each footnote number, just as you requested. Or may be I don't quite understand your point.
|
#11
|
||||
|
||||
![]()
Ho hum:
Code:
Sub InsertFootnote() Dim Rng As Range: Set Rng = Selection.Range Application.Dialogs(wdDialogInsertFootnote).Execute Rng.End = Rng.End + 1: Rng.InsertAfter "a": Rng.Style = wdStyleFootnoteReference Selection.Start = Selection.Start - 1 Set Rng = Selection.Range: Rng.Collapse wdCollapseStart Rng.Start = Rng.Start - 1: Rng.InsertAfter "a": Rng.Style = wdStyleFootnoteReference Selection.Collapse wdCollapseEnd If ActiveWindow.ActivePane.View.Type = wdPrintView Or ActiveWindow. _ ActivePane.View.Type = wdWebView Or ActiveWindow.ActivePane.View.Type = wdPrintPreview Then ActiveWindow.View.SeekView = wdSeekFootnotes Else ActiveWindow.View.SplitSpecial = wdPaneFootnotes End If End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#12
|
|||
|
|||
![]()
Hi Vivka! Yes, Greg's code works without a hitch, but only in the footnotes. Besides, he insists on my being a liar, because I say that my code works, though not exactly as I want.
|
#13
|
|||
|
|||
![]()
Hi macropod! Thank you for your 'ho hum' and for the code. This is what it does:
- in the main document it completely deletes the first footnote and leaves the others unchanged; - in the footnote area it creates '1a' without the footnote content and leaves all the other reference numbers unchanged. Wouldn't it be easier for you experts to modify my code so as to obtain '1a ' instead of '1 a'? Cheers, RobiNew |
#14
|
||||
|
||||
![]()
I suggest you watch your language. I don't see Greg accusing you of being a liar. He simply disagrees with you, which is understandable as you've failed to provide sufficient code to make what you posted work. For starters, there is no sure way to tell what your 'ftNote' variable refers to.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#15
|
||||
|
||||
![]() Quote:
Your problems in this thread are entirely of your own making, for the simple reason that all you've deigned to provide is a code snippet with no context.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Word Macro to Find a phrase followed by a number and a lower case letter, capitalizing the letter | rekent | Word VBA | 2 | 01-14-2025 01:45 PM |
Using text frames in the Footnote area | RRB | Word | 9 | 12-07-2023 02:30 AM |
![]() |
TheBigBoss | Word VBA | 5 | 06-10-2022 06:14 AM |
![]() |
jaanross | Word | 5 | 02-06-2020 12:04 AM |
![]() |
NoCalScribe | Word VBA | 3 | 07-15-2019 07:20 PM |