logo
search
VBA & Macro Problems

How to Hide the Blinking Cursor in an Excel VBA TextBox

Bushra ParveenBushra Parveen Oct 20, 2026 868 views

Question details

The user needs to hide the blinking cursor (caret) in an Excel VBA UserForm TextBox while keeping the text selectable and copyable.

How to Hide the Blinking Cursor in an Excel VBA TextBox
Product
Excel VBA
Device & OS
not provided
Scenario
Creating a UserForm with a read-only text field where users can still highlight and copy the content to their clipboard.
Observed behavior
Disabling the TextBox removes the cursor but completely prevents text selection. Using a Label removes the cursor but does not natively support text copying. There is no built-in property to simply hide the cursor in an active TextBox.
Before you start

Understand that Excel VBA does not natively support hiding the text cursor in an active, selectable TextBox control. You will need to implement a workaround that best fits your user interface needs.

Solution 1Recommended

Workaround 1: Use a Label with a Dedicated Copy Button

Since a TextBox cannot hide the cursor while remaining interactive, you can use a Label to display the text seamlessly and provide a button for users to copy the content.

This is the most reliable method for creating a clean, cursor-free interface in a VBA UserForm while ensuring users can still extract the information they need.

1
Replace TextBox with a Label

In your VBA UserForm designer, remove the TextBox and insert a Label control. Set its 'Caption' property to the text you want to display.

2
Add a CommandButton

Insert a CommandButton next to or below the Label. Change its 'Caption' property to 'Copy Text'.

3
Add VBA Code to Copy to Clipboard

Double-click the CommandButton to open the code editor. Use a DataObject to copy the text. Example code: Dim objData As New MSForms.DataObject objData.SetText Label1.Caption objData.PutInClipboard

Workaround 1: Use a Label with a Dedicated Copy Button
Clipboard Access: Make sure you have added a reference to 'Microsoft Forms 2.0 Object Library' in your VBA project, otherwise the DataObject may not work.
Free Microsoft Office alternative

Try WPS Office for Seamless Spreadsheet and Macro Management

While Excel VBA has certain UI limitations with UserForms, WPS Office provides a lightweight, highly compatible alternative for handling complex spreadsheets and macros. Enjoy familiar tools with robust VBA support without the hefty subscription fees.

  1. 1. Download and Install WPS Office: Visit the official WPS website and download the free installation package for your operating system.
  2. 2. Open Your Macro-Enabled Spreadsheet: Launch WPS Spreadsheets and open your existing .xlsm or .xlsb files without losing any formatting or code.
  3. 3. Access the Developer Tools: Navigate to the Developer tab to open the VBA Editor, modify your UserForms, and execute your macros seamlessly.
Fully compatible with Microsoft Excel (.xlsx, .xlsm, .xls) formatsBuilt-in VBA editor to run, edit, and manage your existing macros securelyLightweight application that runs smoothly even on older devicesFree to download and use for your daily personal and professional office needs
microsoft office alternative - wps office

Frequently Asked Questions

Can I use Windows API calls to hide the cursor in an Excel UserForm TextBox?

Yes, advanced users sometimes use the 'HideCaret' Windows API function. However, this method is highly complex, prone to breaking across different Windows or Office versions (especially 32-bit vs 64-bit), and is generally not recommended for standard UserForms.

Why does setting the 'Locked' property to True not hide the cursor?

The 'Locked' property only prevents the user from typing or modifying the text. It does not prevent the control from receiving focus, which is why the blinking cursor (caret) still appears when the text box is clicked.

Can I disable the TextBox but still allow text copying?

No. Setting the 'Enabled' property of a TextBox to False completely prevents user interaction. Users cannot click, highlight, or copy the text inside a disabled control.