PDA

View Full Version : Header Problem with "text CC F&B"



Webtramp
05-09-2007, 08:33 AM
I have a strange problem.

I?m trying to create a header. The function is triggered on the beforeprint event.

It is supposed to write the follwowing Text "Monatsbericht f?r CC F&B".
I know that I have to put two &s to get one to be displayed.
However if the line of code executes then I can find "Monatsbericht f?r CC F&F" in the header.

I recorded a macro to see what Excel does if I manually enter "Monatsbericht f?r CC F&B".
This is the result: .LeftHeader = "&""MS Sans Serif,Fett""Monatsbericht f?r CC F&&A" :wot
It puts an A.:doh:

If I do the recording procedure but enter "Monatsbericht f?r CC F&A" Excel records: .LeftHeader = "&""MS Sans Serif,Fett""Monatsbericht f?r CC F&&N"

Can someone explain this behaviour to me? :think:

As this code is transferred to many different worksheets where the Header will be created dynamically out of the filename I can not just hardcode the odd solution that Excel gives me.

I would be grateful for any help.

lucas
05-09-2007, 08:47 AM
This works for me.....
Sub a()
With ActiveSheet.PageSetup
.LeftHeader = "Monatsbericht f?r CC F&&B"
End With
End Sub

Charlize
05-09-2007, 02:14 PM
Probably && because with & you can connect variables, codeline over multiple lines, ... (I guess)

Charlize

Webtramp
05-10-2007, 04:56 AM
@lucas.

What language are you using? I guess an english one. I use a german one. A wild guess from my side would be that Excel is so smart and translates the &B which is used for bold to the german equivalent fett.

This results in F instead of B.

Now how can I avoid this?