Getting the user selected text in a text box shapes in xl sheet using vba

Sanmrxl

New Member
Joined
Aug 1, 2007
Messages
36
Hello.. my need is to automate coloring of selected text in a text box shape in xl.
But the first step to get the selected text or the starting position of the cursor in the text box shape itself seems difficult.
( I am not using Active X text box just a normal text box )
Though it seems to be possible to color the text with the mention of starting position and length,
using code line

With Selection.Characters(Start:=10, Length:=9).Font.colorindex = vbred

what I need to is to color the user-selected text, which is a variable.

Thanks in advance.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
The object model does not contain any property or method to fetch selected text. Not that I could find. You could use the clipboard to determine what is being selected and then InStr to determine the start arg. Though there may be multiple possibilities available in the entire text string. Show your method for coloring the selected text. After further consideration, maybe you could call a menucommand on the selected text. I'm betting that you can.
 
Upvote 0

Forum statistics

Threads
1,213,561
Messages
6,114,312
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top