Auto-run macro for footnotes?

D

David

Is it possible to write a macro that runs automatically when you insert a footnote

Thanks
David
 
D

Dave Lett

Hi,

Yes, you will need to intercept Word's command for inserting a footnote, as in the following:

Sub InsertFootnote()

MsgBox "Intercepted Footnote Command."
Dialogs(wdDialogInsertFootnote).Show

End Sub


HTH,
Dave
 
J

Jay Freedman

Hi, David,

Yes, just name the macro InsertFootnote to make it intercept the command.
Try this to see what happens when:

Sub InsertFootnote()
MsgBox "doing my stuff..."
Dialogs(wdDialogInsertFootnote).Show
MsgBox "doing more stuff..."
End Sub

If you want to modify the default selections in the dialog, you can do it
this way:

Sub InsertFootnote()
With Dialogs(wdDialogInsertFootnote)
.Notetype = 1 'endnote instead of footnote
.Reference = "#" ' custom mark
.Show
End With
End Sub
 
D

David

What is the command for changing the font size?

Sub InsertFootnote()

Dialogs(wdDialogInsertFootnote).Show
Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
With Selection.ParagraphFormat
.LeftIndent = InchesToPoints(0.25)
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
.FirstLineIndent = InchesToPoints(-0.25)
'then change the font size to 11
End With

End Sub

Thanks,
David
 
D

Dave Lett

Hi David

You can use something like the following

Sub InsertFootnote(

Dialogs(wdDialogInsertFootnote).Sho
Selection.Font.Size =
Selection.ParagraphFormat.Alignment = wdAlignParagraphJustif
With Selection.ParagraphForma
.LeftIndent = InchesToPoints(0.25
.SpaceBeforeAuto = Fals
.SpaceAfterAuto = Fals
.FirstLineIndent = InchesToPoints(-0.25
'then change the font size to 1
End Wit

End Sub
 
D

David

Is there a way to tell Word to change these attributres on all the footnotes in a document? This will work if you're just starting a footnote list.

Sub InsertFootnote()

Dialogs(wdDialogInsertFootnote).Show
Selection.Font.Size = 12
Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
With Selection.ParagraphFormat
.LeftIndent = InchesToPoints(0)
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
.FirstLineIndent = InchesToPoints(0)
End With

End Sub

Thanks,
David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top