PDA

View Full Version : Symbol Fonts a NoGo in Added Labels



tdm100
09-15-2006, 03:58 AM
I have a UserForm that include two Label Controls
Two more Label Controls are added during run time.

Design Time Labels
.Name = lblSymbl1 , lblLtr1
.Height = 27.75 , same
.Left = 12 , 42
.Top = 12 , same
.Width = 23.25 , same
.Font.Name = "Symbol" , "Arial"
.Caption = tSymbl
.Font.Size = 24 , same
.Font.Bold = True , same

The only variable involved between the two design time Label Controls is the Caption and was initially designed to be input by the user.

The Font Name works with the above scenario.
That is, input for the Caption @ lblSymbl1 produces a "Symbol" Font
and , lblLtr1 an "Arial" Font

The same results are not obtained when the Label Controls are added though.
Specifically, the "Symbol" Font is not recognized by the run time added lblSymbl2 Label control.


Sub WHYnoSymbolFonts()
Dim i As Integer, lbl As Object

Lblz = Array("lblSymbl2", "lblLtr2") 'Label Control Names
zLft = Array(12, 42) 'Left Positions on UserForm

zFnts = Array("Symbol", "Arial")
'Symbol, MS Outlook, Webdings(n).............Fonts that didn't work
'Vivaldi, VOY DOT LCD, SWlogo, Westminster...Fonts, oddly enuff, that did

'Intially designed to be User Input
zCaps = Array("Y", "Y")
tSymbl = "W"

With UserForm1
.lblSymbl1.Caption = tSymbl
.lblLtr1.Caption = tSymbl
For i = 0 To 1
Set lbl = UserForm1.Controls.Add("Forms.Label.1", Lblz(i), True)
With lbl
.Height = 27.75
.Left = zLft(i)
.Top = 48
.Width = 23.25
.Font.Name = zFnts(i)
.Caption = zCaps(i)
.Font.Size = 24
.Font.Bold = True
End With
Set lbl = Nothing
Next i
.Show
' ...
End With
End Sub

Also tested, not using a variable for
.Font.Name = zFnts(i)
but to write it as
.Font.Name = "Symbol"
with the same unfortunate result
It did NOT recognize it

Anyone know what the HECK is goin on?
Thanx in advance if you do

tdm100
09-15-2006, 07:44 AM
Oh MAN,,, I hate when this happens!
You're movin along, creating that killer VB app, and then all of a sudden, SNAG!
"WTF!"
"Why aint that working?!"

You check and you check, reread, reread, debug, debug, then YES, you eventually succumb and hafta to click on the dreaded Mr. PaperClip Help Icon.
"He is such a dork!"

Because of the male ego, you look over your shoulder to make sure the coast is clear for fear if someone catches you using it.
You quickly click it, only to hear one of your female colleague's break the secretive silence with
"Aww, isn't that Clip cute?"
"And he is so helpful too"
"Dontcha think?"
Groan

You traipse through the help files,, grumbling over a bruised ego, mumbling to yourself "I know where you can stick that pencil and pad Clip"
"Yeah I'm talking to you,,,you scrawny bugged eyed thing you!"
"Don't think you're nappin on my time either buddy!"
Yeah,,,empowerment,,,I'm starting to get my ego back.

"Hey lookie here!"
"I did not know that"
"That don't help me a dang right now,,,but that might help me in future projects"
"What the heck was I looking for,,,oh yeah"
"And why was I looking for it?"
"Oh man,,,I lost my train of thought on my Killer App!"
Groan!

24 hours later, I finally found the frickin answer!
I use Excel2000 and apparently this is referred to as a "Hidden" Property.
Supposedly tucked away in the Object Browser section.
On my system, it's so hidden, I didn't see it there either.

The solution to the problem is
.Font.Charset = 2



Sub SymbolFontsWorkNow()



Dim i As Integer, lbl As Object


Lblz = Array("lblSymbl2", "lblLtr2") 'Label Control Names
zLft = Array(12, 42) 'Left Positions on UserForm




zFnts = Array("Symbol", "Arial")




'Intially designed to be User Input

zCaps = Array("Y", "Y")
tSymbl = "W"


With UserForm1
.lblSymbl1.Caption = tSymbl
.lblLtr1.Caption = tSymbl
For i = 0 To 1
Set lbl = UserForm1.Controls.Add("Forms.Label.1", Lblz(i), True)
With lbl
.Height = 27.75
.Left = zLft(i)
.Top = 48
.Width = 23.25
.Font.Name = zFnts(i)
.Font.Charset = 2 'Important for the Symbol Font to work
.Caption = zCaps(i)
.Font.Size = 24
.Font.Bold = True
End With
Set lbl = Nothing
Next i
.Show
' ...
End With

End Sub



.Font.Charset = 2
Where it comes from & why it works,,, I have no idea!
It's not in my Help File or Object Browser.

If someone would care to shed some light on this, I'd appreciate it.
I would also like to know,,,, is there a source of Hidden Properties?
A place where they have a list of these things?

ALe
09-15-2006, 08:17 AM
tdm100, I can't answer your question but I just wanted to tell you sure are a great novelist! I enjoyed your thread so much.

thanks

tdm100
09-15-2006, 08:22 AM
:)
All derived from frustration
lol

ALe
09-15-2006, 08:39 AM
it could be the case it was an old property of previous versions.

I found this article on replaced properties and methods
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexcl2k/html/xlwhtsnw.asp

tdm100
09-15-2006, 09:24 AM
Well LOOKIE here!

Hidden Objects
Hidden Properties and Methods
To view hidden objects in the Object Browser, right-click anywhere in the Object Browser window and then click Show Hidden Members on the shortcut menu.

Charset As Integer
Member of MSForms.NewFont

It is on my system!
Unfortunately....No Help Available
(figures,,lol)


Interestingly enough,, majority of my initial search for this Font dilemma, I kept running into a lot of what's written on the web page.
Especially the DataLabel info.

I was going "Dang, I'm not doin DataLabel!"
"I'm doin Label Controls Paper Clip!"
"Quit toyin with me man"

Thanx ALe

Bob Phillips
09-15-2006, 10:03 AM
Why are you craeting controls on the fly, never a good idea?

Why not create them at design time, and hide them until you need them?

tdm100
09-15-2006, 11:17 AM
Why are you craeting controls on the fly, never a good idea?

Why not create them at design time, and hide them until you need them?

The Code presented here is in "part" and a "slight representation" of the original full code.
In the full version the variables derived are dependent on User input and collected via Dynamic Multidimensional Arrays.
For example the size and color of this particular UserForm is not known until just before presentation.
Again, dependent on User input.
It is possible, depending on the user choices, to have NO Label Controls presented at all on this user form. That is the desired effect, if deemed necessary or option driven.


The code I presented here is simply to pose the question.
But make no doubt about it, the dilemma presented here was a stigma in my full version code!
And I am at great relief that I found a solution.

Unfortunately, I am one of those people that, though they have found a remedy, are not satisfied unless they can fully explain it. (understand it)

Where in the heck did this Charset Property come from and why is it hidden?!
(For example)

I am amazed I haven't come across this Font problem before.
This aint my first version of Excel I've played with
But then again, it's not to often that I require the use of Symbol Fonts in order to complete a task.

Now, if you be so willing,,,,
elaborate on your suggestion that adding controls "on the fly" is "NEVER A GOOD IDEA"

Bob Phillips
09-15-2006, 11:45 AM
- it makes the code less readable
- it makes the code less maintainable
- event procedures for run-time added controls are difficult to add

it's smart-alec code IMO, not necessary.

tdm100
09-15-2006, 12:01 PM
- it makes the code less readable
- it makes the code less maintainable
- event procedures for run-time added controls are difficult to add

it's smart-alec code IMO, not necessary.


That reads hauntingly familiar to the definition of the
Outcome-Based Education System
And dang if that aint doin a fine job!

"It's too frickin hard, and I'm too dang lazy"
"Here's your diploma"

Thanx for your response & your candor

Bob Phillips
09-15-2006, 12:50 PM
That reads hauntingly familiar to the definition of the
Outcome-Based Education System
And dang if that aint doin a fine job!

"It's too frickin hard, and I'm too dang lazy"
"Here's your diploma"

Thanx for your response & your candor

I have no idea what Outcome-Based Education System is, but I think I understand your comment, which validates what I said earlier.

tdm100
09-15-2006, 02:13 PM
I have no idea what Outcome-Based Education System is, but I think I understand your comment, which validates what I said earlier.

Oh!
Forgive me
You maybe familiar with the alternative used term
"Dumbing Down"

It's easier to grasp using that term,,,, yeah?
Less effort for sure,,,yes?

Bob Phillips
09-15-2006, 03:59 PM
I don't consider it dumbing-down to keep something simple and straight-forward. I consider that good design, good product, and good customer service. Where necessary, add the bells and whistles, or if on the leading edge, but a userform doesn't come anywhere near any of thsoe categories.

Perhaps you have never had to come in and pick of the pieces after programmers who thought they were smart, and tried to figure your way through the inherent jumble.