vba - How can I select (or copy) text from a Word 2010 ActiveX label? -


a word 2010 document has activex label displays text. there way make text selectable, or otherwise copy-able, user's point of view, can paste somewhere else?

use case: give form someone, fill out , return me. element in question label which, when double clicked, produces userform1 has listbox on it. once 1 or more selections made , user presses ok on userform1, label in word doc gets updated. receive form back, , want right click label, copy text, , paste email.

you can't, @ least end-user's point of view. let me explain.

i started out wanting achieve label, found couldn't copy text displayed there using conventional ctrl-c or right-click > copy.

so, switched textbox. worked somewhat, , data displayed, though 1 flaw: word 2010 seems put bunch of unselectable space between last line in textbox , bottom of textbox, making contents hidden until scrolled top of it.

here's looked like:

comparison of textbox vs label approach before fix

notice empty, unselectable space below last item in list?

the solution problem of 100% of text not being displayed in box use line of code, places cursor @ top of text after values placed in textbox:

thisdocument.functionalcomponentstextbox.selstart = 0 

this simulates user manually clicking in textbox , pressing key until reaches top of textbox. that, selections listbox stored in textbox, contents of can copied , pasted wherever part of our business processes.

here's looks after: perfect match when compared properly-displayed label approach! added bonus: text selectable, , textbox customizable removed border it... can't tell difference!

comparison of textbox vs label approach after fix


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -