473,566 Members | 3,273 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Proper syntax for changing font color in excel header/footer

18 New Member
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 25741
NeoPa
32,564 Recognized Expert Moderator MVP
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
svdoerga
18 New Member
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,564 Recognized Expert Moderator MVP
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
svdoerga
18 New Member
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,564 Recognized Expert Moderator MVP
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
Sylvain MARBACH
2 New Member
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,564 Recognized Expert Moderator MVP
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
Sylvain MARBACH
2 New Member
@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,564 Recognized Expert Moderator MVP
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
6224
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 anyone know what code to use.
4
19611
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 size????
7
8939
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 then change the label in front of the textbox or dropdown list to red... is this possible with asp.net? It seems you can only put a...
0
1016
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
39999
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 text is not just the regular white color but maybe blue, red, green, etc. Thanks Erik
4
2858
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
1722
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 MFC..?? because I never deal with MFC?? thank a lot :D
3
8271
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 'admin/config.php';
0
8109
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7645
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7953
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1202
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.