ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Font in Header - @22 "25 Miles" goes to 409 font (https://www.excelbanter.com/excel-programming/434033-font-header-%4022-25-miles-goes-409-font.html)

BlueWolverine

Font in Header - @22 "25 Miles" goes to 409 font
 
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.

--
BlueWolverine
MSE - Mech. Eng.
Go BLUE!

Dave Peterson

Font in Header - @22 "25 Miles" goes to 409 font
 
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"



BlueWolverine wrote:

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.

--
BlueWolverine
MSE - Mech. Eng.
Go BLUE!


--

Dave Peterson


All times are GMT +1. The time now is 01:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com