Word 2010 中修改文本框的复选框

发布于 2025-01-04 15:12:54 字数 159 浏览 0 评论 0原文

我想要一个 MS Word 2010 文档,其中有一个复选框(可检查)和一个文本框(文本字段),其中根据是否单击复选框显示不同的文本。

我尝试过搜索它,但不知何故,所有建议并不意味着作为复选框问题的解决方案...

我认为该解决方案应该在 Visual Basic 中使用?

I want to have a MS Word 2010 document where there is a checkbox (ckeckable) and a textbox (textfield) where different text is displayed depending on whether the checkbox is clicked or not.

I have tried searching for it but somehow all the suggestions are not meant as solutions for the checkbox question...

I would think that the solution should be used in Visual Basic?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

万水千山粽是情ミ 2025-01-11 15:12:54

像这样的东西吗?

Private Sub CheckBox1_Change()
    If CheckBox1.Value = True Then
        TextBox1.Text = "Checked!"
    Else
        TextBox1.Text = "Unchecked."
    End If
End Sub

假设您有一个名为 CheckBox1 的复选框和一个名为 TextBox1 的文本框。上面的代码位于 ThisDocument 模块中。

结果看起来像这样 在此处输入图像描述 和这个 在此处输入图像描述

编辑 哎呀,我用 Excel 制作了这些图片...哦,好吧,它们在 Word 中看起来几乎一模一样。

编辑您现在更改了要求,并希望在取消选中该复选框时“隐藏”文本框。没有正式的方法来“隐藏”文本框,但您可以删除它的可见功能,即它包含的文本以及“凹陷”特效,这样它就无法与背景区分开来:

Private Sub CheckBox1_Change()
    If CheckBox1.Value = True Then
        TextBox1.Text = "Checked!"
        TextBox1.SpecialEffect = fmSpecialEffectSunken
    Else
        TextBox1.Text = ""
        TextBox1.SpecialEffect = fmSpecialEffectFlat
        'Textbox is now "invisible"
    End If
End Sub

Something like this?

Private Sub CheckBox1_Change()
    If CheckBox1.Value = True Then
        TextBox1.Text = "Checked!"
    Else
        TextBox1.Text = "Unchecked."
    End If
End Sub

This assumes you have a checkbox called CheckBox1 and a text box called TextBox1. The above code goes in the ThisDocument module.

Result looks like this enter image description here and this enter image description here.

EDIT Whoops, I made these pics in Excel... Oh well, they look almost identical in Word.

EDIT You have now changed the requirement and want the textbox to "be hidden" when the checkbox is unchecked. There is no formal way to "hide" a textbox, but you can remove it visible features, i.e. the text it contains as well as the "sunken" special effect, such that it is indistinguishable from its background:

Private Sub CheckBox1_Change()
    If CheckBox1.Value = True Then
        TextBox1.Text = "Checked!"
        TextBox1.SpecialEffect = fmSpecialEffectSunken
    Else
        TextBox1.Text = ""
        TextBox1.SpecialEffect = fmSpecialEffectFlat
        'Textbox is now "invisible"
    End If
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文