Font in Header - @22 "25 Miles" goes to 409 font

B

BlueWolverine

Hello,

MS EXCEL 2003 in XP PRO (Actually controlled from vba in access 03)

Hello.

I am trying to set the header in vba for the print area in excel. The code
is right but the problem is if the variable starts with a number.

..CenterHeader = "&""Copperplate Gothic Bold,Bold""&22" &
CStr(in_ChecklistName & " Checklist")

if in_ChecklistName starts with a number, it contributes to the font size.

So if

in_ChecklistName = "25 Mile Drive"

then it behaves as if the code read like so.

..CenterHeader = "&""Copperplate Gothic Bold,Bold""&2225"" Mile Drive"

Which obviously causes the header font to go HUGE.

What can I do to fix this? Note: works perfectly if the in_ChecklistName
variable starts with a letter.

Thanks.
 
D

Dave Peterson

put a space between the characters:

..CenterHeader = "&""Copperplate Gothic Bold,Bold""&22 " _
& CStr(in_ChecklistName & " Checklist")

or

..CenterHeader = "&""Copperplate Gothic Bold,Bold""&22" & " " _
& CStr(in_ChecklistName & " Checklist")

I'd drop the cStr() stuff. VBA will see it as a string since you're
concatenating strings

..CenterHeader = "&""Copperplate Gothic Bold,Bold""&22 " _
& in_ChecklistName & " Checklist"
 

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