473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Proper syntax for changing font color in excel header/footer

I am wondering how you can change the fontcolor in the header or footer in VBA when exporting to excel. I need some text in red. I found the ms page with the codes here. It's saying the formatting is &color and it should be a hexadecimal value. Then on the bottom of the page it says K[color]. I've tried a lot of things like:

&Kff0000
&K[ff0000]
&ff0000
&[ff0000]
&colorff0000
&color[ff0000]

but none are working. Anyobody know the proper syntax?
Jul 31 '08 #1
9 25664
NeoPa
32,556 Expert Mod 16PB
Are you sure this is even possible.

I didn't find any reference to colours when I looked at the manual interface to this in the Font screen.

Tip:
In Excel when curious how to do something in VBA that you can do as an operator :-
Select Tools / Macro / Record New Macro.
From there do the action you are curious about (in this case File / Page Setup... / Custom Header / Font (button)) then see what is created in the VBA editor under VBAProject / Modules / Module1.

I was able to tell that setting the font name and size was :
Expand|Select|Wrap|Line Numbers
  1. ActiveSheet.PageSetup.CenterHeader = "&""Arial,Bold""&14ggg"
Aug 5 '08 #2
Are you sure this is even possible.

I didn't find any reference to colours when I looked at the manual interface to this in the Font screen.

Tip:
In Excel when curious how to do something in VBA that you can do as an operator :-
Select Tools / Macro / Record New Macro.
From there do the action you are curious about (in this case File / Page Setup... / Custom Header / Font (button)) then see what is created in the VBA editor under VBAProject / Modules / Module1.

I was able to tell that setting the font name and size was :
Expand|Select|Wrap|Line Numbers
  1. ActiveSheet.PageSetup.CenterHeader = "&""Arial,Bold""&14ggg"
Thanks for the tip, that will come in handy :)

I found out that it is impossible to change font color in a header in excel 2003. It is possible in excel 2007 though.

A trick to get around the inability to change fontcolor in the header, is to format the first row(s) in the sheet, and assign it (or them) as header from: File->Page setup->Sheet->Print titles->rows to repeat/columns to repeat
Aug 6 '08 #3
NeoPa
32,556 Expert Mod 16PB
8-) (or Cool for the uninitiated :->)

The macro recording tip I find invaluable even now after some years coding in Excel VBA.

PS. I don't touch Office 2007 with a bargepole - my stuff is all 2003 & before related.
Aug 6 '08 #4
8-) (or Cool for the uninitiated :->)

The macro recording tip I find invaluable even now after some years coding in Excel VBA.

PS. I don't touch Office 2007 with a bargepole - my stuff is all 2003 & before related.
I've been using the macro recorder the last days...it's awesome :) Saves me a lot of time trying to find out how to do stuff on the net! :D
Aug 7 '08 #5
NeoPa
32,556 Expert Mod 16PB
Marvellous!

Very pleased to hear it :)

I should add a warning not to rely too heavily on the code it produces mind-you. It's automatically generated and generally quite clumsy.

As a resource to point you at where you should be starting from though, as you say, it's invaluable.
Aug 7 '08 #6
For Excel 2007, there is indeed a way to change font color in header/footer.

Just use the following syntax : "&K" + color value in hexadecimal ; for example to turn font to red, use "&Kff0000"

Not well documented...
Aug 23 '10 #7
NeoPa
32,556 Expert Mod 16PB
I imagine the OP knew about this already Sylvain - hence the inclusion in the first post. Are you suggesting there is some way this can be used that is not evident? Perhaps you could explain if so. As it is, your post simply repeats what was included in the question.
Aug 23 '10 #8
@NeoPa
I spent a lot of time to tackle this problem. My intend was just to summarize for those who are still searching for a solution to colorize some part of a header/footer:
Excel 2003 and before = not possible
Excel 2007 and after = possible
Among all proposed syntaxes in the first post, only one is working = "&Kff0000" for red... or "&Kc71585" for medium-violet-red and so on
Aug 23 '10 #9
NeoPa
32,556 Expert Mod 16PB
Sylvain:
I spent a lot of time to tackle this problem.
I applaud you for that.

It would be a shame then, if your answer were unable to help anyone.

In the first post, Svdoerga says they've tried &kff0000 and it didn't work. You say you have found a way to make it work in Access 2007 and beyond. Svdoerga doesn't say which version they're using (which is unfortunate as all questions should have this information for just such situations as this), but whichever version they're using, either doesn't work with your solution, or can be made to work using your technique. My point was that you didn't say anything about a technique (or any special instructions needed to make this work), so the solution is either not right for the question (even though this is mainly confused by Svdoerga not posting the question properly), or it is right but missing important information.

It would be a shame for you to spend that much time and for no-one to be able to benefit from it no?
Aug 24 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: jeffgeorge | last post by:
Working on a report oriented application. One of the columns on a form needs to be red, black or blue depending of the value in that column. Can I write an expression to handle this or does...
4
by: John hoffman | last post by:
Hello, I am trying to set the MS Excel header and footer font using automation from C#. I can set the text using: oPageSetup.LeftHeader = "Header Text"; but how do you set the Font...
7
by: Ed West | last post by:
Hello, I have a simple form with some input boxes. After validation if one fails, then I would like to at the top of the page say something like "The following fields in red are required" and...
0
by: Patrice | last post by:
The following code : Public Class c Shared Sub main() Dim obj As Object Dim wbk As Object Dim wks As Object obj = CreateObject("Excel.Application") 'bj.Visible = True wbk = obj.WorkBooks.Add
3
by: Icarus27 | last post by:
I am writing a program for my Computer Science class and I am making a game for extra credit. What I need to know is how do you change the font color so that when it prints out on the screen the...
4
Ali Rizwan
by: Ali Rizwan | last post by:
How can i change font color and background color in c or c++. Plz give an example . Thanx
1
by: dreams | last post by:
hi every one :) is there any one knows how to change the font color for a specific such as a key word,, and which library should I include if there is any one,, also... is it going to work on...
3
by: petrakid | last post by:
I have a table called oth_recruitment In the table are 10 fields. Each field will have only 1 entry: Open or Closed. On my website, I have the following code: <?php include...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.