activeX text box edit mode

  • Excel Version 2010
    I am using VBA to input a time stamp into an activeX textbox. Following is code:
    'Time stamp command button.
    Dim CurTime
    CurTime = Format(Now(), "hh:mm" & " - ")
    Worksheets("TrendView").Shapes("TextBox1").OLEFormat.Activate
    TextBox1.Select
    TextBox1.Text = TextBox1.Text & CurTime
    Issue is that once time stamp is inserted you must click back into the box to type anything further. My preference is that you could start typing immediately but I can see no way to enable that. I have another section with a merged cell and by simply using Sendkeys F2 issue is resolved there but does not work in activeX textbox. The activeX textbox is inserted onto a worksheet and is not in a form.


    Thank you in advance for any assistance you may have to offer.


    Sincerely,


    Chris Williams

  • Jonathan,
    Thank you so much. Your code is much more compact than mine. However I am getting the same result when executing code. It inputs time stamp into activeX box but then requires I click in the box to enter text. I know it seems picky but I am trying to maintain a consistent interface between several worksheets. Thank you again.

  • On my system (Excel 2016, 64-bit), it puts the cursor insertion point at the end of the text in the control. I.e., if I run the code and start typing, what I type is in the textbox following the time. Perhaps your subroutine includes code after this that activates some other location. Try just the above code in a subroutine and run that.

  • Jonathan,
    You hit the nail on the head. I created a new workbook, input text box and ran code. All is fine there. It is a problem with other code being executed when this fires. Thank you! Can you advise how I flag this resolved? Once again, THANK YOU!

  • I don't know. I'm new here, but I don't think this system supports that process. You could click on the Like button at the lower right of my post, as I infer, from other dialogues, that does something.


    The goal is to have a useful forum history for others to search, so your last posts should denote closure.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!