表单文本框数据输入导致工作表表单按钮不起作用 [英] Form textbox data entry causes worksheet form button not to work
问题描述
我有一个数据输入工作表(excel2010),其中包含在运行时创建的多个表单文本框(使用下面的代码),几个按钮和几个组合框(没有一个是activex)。
I have a data entry worksheet (excel2010) with multiple form text boxes created at runtime (using below code), several buttons, and several combo boxes (none are activex).
Dim tBox As TextBox
Dim tBox As TextBox
Dim tShp As Shape
Dim tShp As Shape
    设置tShp =表格(sht).Shapes.AddTextbox(msoTextOrientationHorizontal,.Left,.Top,.Width,.Height)
    使用tShp
              .DrawingObject.Font.OutlineFont = False
              .DrawingObject.Font.Shadow = msoFalse
              .DrawingObject.Font.Size = 10
              .TextFrame2.TextRange.Characters.Font.Line.ForeColor.RGB = RGB(0,0,0)
              .TextFrame2.TextRange.Characters.Font.Line.Visible = False
              .TextFrame2.TextRange.Characters.Font.Line.Transparency = 0
              .TextFrame2.TextRange.Characters.Font.Bold = msoFalse
              .TextFrame2.WordWrap = msoFalse
        结束与        
        设置tBox = tShp.OLEFormat.Object
        使用tBox
            .Locked = True
            .LockedText = False
            .PrintObject = False
            .name =" Textbox" '名称在真实代码中传递给此程序
         结束于
Set tShp = Sheets(sht).Shapes.AddTextbox(msoTextOrientationHorizontal, .Left, .Top, .Width, .Height)
With tShp
.DrawingObject.Font.OutlineFont = False
.DrawingObject.Font.Shadow = msoFalse
.DrawingObject.Font.Size = 10
.TextFrame2.TextRange.Characters.Font.Line.ForeColor.RGB = RGB(0, 0, 0)
.TextFrame2.TextRange.Characters.Font.Line.Visible = False
.TextFrame2.TextRange.Characters.Font.Line.Transparency = 0
.TextFrame2.TextRange.Characters.Font.Bold = msoFalse
.TextFrame2.WordWrap = msoFalse
End With
Set tBox = tShp.OLEFormat.Object
With tBox
.Locked = True
.LockedText = False
.PrintObject = False
.name = "Textbox" ' name passed to this procedure in the real code
End With
    结束
End With
此外,在工作表上还有几个表单(非activex)控件按钮,用于触发宏以处理单击按钮时输入的数据。 问题是,当在任何文本框中输入文本,然后将鼠标移动到命令按钮时,点击那里的
不起作用(忽略点击)。 如果您转到第二个按钮,它可能会起作用,也可能不起作用。有时你需要点击类似组合框的东西(也在数据输入屏幕上) 首先,然后命令按钮点击将
工作。 似乎在文本框中输入内容后,即使您在文本框外单击,它也会保持焦点。 另请注意,文本表单控件位于受保护的工作表上(上半部分用于文本框数据输入,下半部分是显示
结果的位置)。 有没有人对这个问题有任何想法?
Also on the worksheet are several form (not activex) control Buttons that fire macros to process the data entered when the button is clicked. The problem is that when text is entered in any of the textboxes, then moving the mouse to the command button, clicking there does not work (click is ignored). If you move to a second button it may work or it may not work. Sometimes you need to click on something like a combo box (also on the data entry screen) first, then the command button clicks will work. It seems that after entering something into the textbox, it keeps the focus even if you click outside the textbox. Also note the text form controls are on a protected worksheet (top half is for the textbox data entry, bottom half is where results are displayed). Does anyone have any ideas on a work around for this problem?
谢谢提前
Allan
推荐答案
你好AllanCr,
我很难重现你的情况。
你可以通过云端存储分享你的文件,例如Dropbox,OneDrive吗?
(删除重要的私人数据)
问候,
Ashidacchi
Hi AllanCr,
I can hardly reproduce your situation.
Could you share your file via cloud storage, such as Dropbox, OneDrive?
(with removing critical, private data)
Regards,
Ashidacchi
这篇关于表单文本框数据输入导致工作表表单按钮不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!