Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textbox Handle in VBA

Status
Not open for further replies.

mjb698

Technical User
Jan 19, 2007
2
GB
I have searched the web, the forum etc. and perhaps I'm just looking in the wrong place so if somebody can either answer this question or point me in the right direction I would be eternally grateful.

I am using excel (Office XP).
I have used vba to produce a wizard which allows the user to enter data. This data is then entered into a log and can also be copied into a pro-forma which can be printed to produce a hard copy.
I am using a number of multiline textboxes as part of the data entry (there is no alternative due to the nature of the data). When this data is transferred to the form, I need a way to control how many lines are entered into the form and then transfer the rest of the data to another pro-forma ("the continuation sheet"). I have been looking at the sendmessage API function to allow me to manipulate the lines of data in the multiline textbox. The problem is that I need to establish the handle of the textbox and the "hwnd" property does not work in vba (only vb). Is there an alternative?
 
Take a look at the "Line" property in "FileSystemObject" properties, in vba help.
There are many ways to manage lines.
This maight be an easy one.
Hope this helps.
Regards.
Nick
 
I am confused. What has FSO got to do with a textbox? The textbox is not a file.

I am also confused by the use of "handle". The texbox is an object and has properties, and if I understand correctly, what you want to do is manipulate the values of the textbox. That is just a string.

Gerry
My paintings and sculpture
 
A starting point.
The number of vbLf in strText is:
Len(strText) - Len(Replace(strText, vbLf, ""))

You may also consider the Split and UBound functions.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for all your help.

My real problem is that the user may not press the enter key at the end of a line in the multiline textbox, i.e. they keep on typing and the cursor automatically moves onto the next line in the text box. If I use the split function, I am only able to extract the contents of the multiline textbox between the points where the user presses the enter key. I need to extract the individual lines of the multiline textbox and assign them to specific cells (e.g. I may want to put the first three lines in one cell and then the remainder in another cell). The topics I find related to this are for vb (not vba) and tell me to use the sendmessage API function to obtain the individual lines of the multiline textbox.

Any help would again be much appreciated! MJB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top