如何在插入到工作表的非activex文本框上使用VBA激活入口模式?

问题描述:

我手动将非activex文本框放在工作表上。如果我为它分配一个宏,然后单击文本框按预期运行宏。如何在插入到工作表的非activex文本框上使用VBA激活入口模式?

但是,入口模式并未在文本框中启用。宏如何将文本框放入入口模式?

请注意,这是从插入功能区插入的文本框。

enter image description here

THX

我前不久发布上述问题之前发现了答案:

Sub Activate_Textbox() 
      ' stuff to do before edit mode... 
      ' ... 

      ' get textbox name 
      Dim sName As String 
      sName = Application.Caller 

      ' get textbox shape object 
      Dim txtBox As Shape 
      Set txtBox = ActiveSheet.Shapes(sName) 

      ' enter edit mode (put cursor into textbox) 
      txtBox.TextFrame2.TextRange.Select 

      ' cleanup 
      Set txtBox = Nothing 
End Sub 

推荐给保护工作表,否则你会看到在文本框中选择手柄时,有重点。并且,如果您保护表单,则需要解锁文字,以便您可以键入文字:

enter image description here