Hi,
I have a frame on my UserForm and what I want to know; is there any way to adjust the caption of a frame to the center instead of upper left hand side
Thanks in advance
Hi,
I have a frame on my UserForm and what I want to know; is there any way to adjust the caption of a frame to the center instead of upper left hand side
Thanks in advance
Not directly, but if you set the caption to nothing you can then use a label positioned in the centre, this will have the same visual effect
K :-)
Hi,
I don't believe there is a property that will align the frames caption.
This routine will centered the text by adding padding characters to the text.
Note the border on the top left of the frame will not appear.
Hi Killian, how close can you get the label to the border of the frame?Sub CenterFrameTitle(MyFrame As MSForms.Frame) Dim strBuf As String Dim labTemp As MSForms.Label Set labTemp = Me.Controls.Add("Forms.Label.1", "labTemp", True) strBuf = Trim(MyFrame.Caption) With labTemp With .Font .Name = MyFrame.Font.Name .Size = MyFrame.Font.Size .Bold = MyFrame.Font.Bold .Italic = MyFrame.Font.Italic End With .WordWrap = False .AutoSize = True .Caption = strBuf Do While .Width < (MyFrame.Width - 20) ' frame title insert slightly strBuf = " " & strBuf & " " ' pad caption .Caption = strBuf Loop End With Controls.Remove "labtemp" Set labTemp = Nothing MyFrame.Caption = RTrim(strBuf) End Sub
when I tried that the label is either partially covered by the frame or the label becomes contained within the frame and the top half vanishes.
Cheers
Andy
My apologies... I just looked for a project where I did this and guess what? I found I couldn't. My solution at the time was to use an image control with the SpecialEffect property set to etched with a label where I wanted it (I actually wanted two captions on the frame but with the etched line between them.
This was fine for me since it was a purely cosmetic use of frames. If you need any of the frame's control functionality it won't help
K :-)
Thanks for the answers,
Andy,
I tryed the solution you mentioned and I think without upper left line, the frame didn't look good.So better off using the default caption position.
Thanks again
Hi,
How about adapting Killian suggestion.
Use 2 labels, one to hold the text and the other to provide the border.
On top of that place a frame control. Format the frame to have no caption and no border.
It now looks like the frame has a centered title and the real frame control can be a container for other controls.
Cheers
Andy
Hi Andy,
I have attached a file that the result of Killian's answer and I have to say it is looking good.
Killian,
Thanks for the tip