Reputation: 328
Can you change the font format of a value you add into the footer of a document ? I could already achieve the value itself but can't seems to find the way to change the format of it.
This is the code I have:
Sub SetValueInFooter()
Dim WorkRng As Range
On Error Resume Next
'make variable with the number
Dim TextINeed As String
TextINeed = ActiveWorkbook.Sheets("Sheet1").Range("A1").Value
'add the number into the footer left
Application.ActiveSheet.PageSetup.LeftFooter = TextINeed
'define style of the number (this 'with' section has no effect, text stays black font size 10)
With ActiveSheet.PageSetup.LeftFooter
.Font.Size = 8
.Font.Color = RGB(192, 80, 77)
End With
End Sub
Thanks for your time & help
Upvotes: 0
Views: 1016
Reputation: 7567
The page setting is different from that of the normal cell. It is helpful to record macros to identify patterns.
Sub SetValueInFooter()
Dim WorkRng As Range
Dim Ws As Worksheet
Dim TextINeed As String
Set Ws = ActiveSheet
'On Error Resume Next
'make variable with the number
TextINeed = ActiveWorkbook.Sheets("Sheet1").Range("A1").Value
'add the number into the footer left
'Application.ActiveSheet.PageSetup.LeftFooter = TextINeed
'define style of the number (this 'with' section has no effect, text stays black font size 10)
With Ws.PageSetup
.LeftFooter = "&8&kc0504d" & TextINeed '<~~ 8:=font.size / c0504d:=font.color (html color) / TextINeed:= text
End With
End Sub
Upvotes: 1