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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
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,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

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