在VBA上编辑表单控件标签标题 [英] Edit Form Control Label Caption on VBA

查看:117
本文介绍了在VBA上编辑表单控件标签标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试编辑名为 lblsearchreminder 的表单控件标签的文本,并确保字体为Arial且大小为20.标签的标题.如果有人有任何见识,我将不胜感激.

Trying to edit the text of a form control label named lblsearchreminder and make sure that the font is Arial and size 20. I am pulling the edited text from an ActiveX textbox1 and trying to make that the caption of the label. If anyone has any insight I would greatly appreciate it.

Sub btnAltCustomSearch_Click()

    Dim strTextBox As String

    If Worksheets("User Interface").OLEObjects("TextBox1").Object.Value = "" Then
        ErrorX.Show
    Else
        strTextBox = Worksheets("User Interface").OLEObjects("TextBox1").Object.Value
        Worksheets("Muscle Wasting Database").Shapes("lblsearchreminder") = vbCrLf & "Disease: All" & vbCrLf & vbCrLf & "Keyword: " & strTextBox
        lblsearchreminder.Object.Characters.Text = "Arial"
        lblsearchreminder.Object.Font.Size = 20

    End If

End Sub

推荐答案

是的,textbox1是一个ActiveX文本框控件,但理想情况下,我将使用表单控件"标签.因此,我试图从ActiveX文本框中提取输入内容,并在 Form Control标签 – Thor Nagel 3小时前

Yes the textbox1 is an ActiveX textbox control, but I will ideally use a Form Control label. So I am trying to pull the typing from the ActiveX textbox and use it in the Form Control label – Thor Nagel 3 hours ago

不幸的是,您无法操纵表单控件标签"的字体大小/名称,颜色或样式.如果您注意到Excel功能区上的字体"组中的格式设置项目已显示为灰色".

Unfortunately you can't manipulate the font-size/name, color or style of a Form Control Label. If you notice the formatting items have been "grayed out" in the Font group on the Excel Ribbon.

设置文本很容易

Dim lblsearchreminder As Shape
Set lblsearchreminder = Sheet1.Shapes("Label 1")
lblsearchreminder.TextFrame.Characters.Text = "Hello"

但是您不能这样做(即使Intellisense允许)

lblsearchreminder.TextFrame.Characters.Font.Name = "Arial"

lblsearchreminder.TextFrame2.TextRange.Characters.Font.Name = "Arial"

我建议改用 TextBox 形状或 ActiveX标签.

类似地,您不能使用

lblsearchreminder.TextFrame.Characters.Font.Size= 20

这篇关于在VBA上编辑表单控件标签标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆