Insert macro generated text into a textbox?

I’m looking for a method to insert text into a Base form textbox either via macro generated text or via LO’s AutoText function.

More specifically, I am attempting to use a push button form control linked to a simple text macro to input text into a text box form control. I have been able to set up a push button form control to input text via a macro into a Write document without difficulty. However, I can’t get the same text to input into a text box when the text box has focus and the push button is activated. I did select NO on the “take focus on click” form control option for the push button, but this made no difference.

I have also tried inserting AutoText into a textbox form control without success. Again, I was able to successfully set up the desired autotext and insert it into a Write document via control/F3, but this function does not work properly when the cursor is within a text box contained in a Write document.

In more general terms, I have an image with several invisible push button “hot spots” overlayed on the image. Each push button is linked to a different text descriptor that I would like inserted into a text box when the push button is activated via a mouse click. For example, let’s say that the background image is a face. I have push buttons overlaying the eyes, nose, mouth, ears, etc. When the push button is activated over the nose, I would like the text “nose” to appear in the text box that has focus (i.e., has the cursor located within the textbox).

Is what I’m attempting possible in LO? If not, can anyone think of an alternative method to accomplish the same task utilizing LO?

Thanks in advance,

docbda

This is very simple using macros. Attached is an example base file PBText.odb

To elaborate just a bit, a macro is called from the Execute action event of each push button. Each tiny macro has a string which is sent to another macro which is then displayed in the text box.

I’ve slightly changed the sample to demo the ability to do what you are looking for. I changed the string to global and simply concatenated the next string. Then added a clear button to start over.

Thanks Ratslinger. Super impressed that you took the time to write those macro examples. I didn’t bring up a couple of issues with my original question. 1. The text being input by the button macros needs to be appended to text that the user has already added to the text box via the keyboard. Will your solution add to text that is already in the text box or over-write it? 2. More than one push button text result needs to be added to the same text box. I guess #2 is another way to ask #1

Thanks, again!
docbda

I can almost see this question coming so I’ll answer it before you ask. If you DON’T want an item appended that has already been selected you can do that simply by setting a global def as boolean and in the appropriate click macro check if Yes(1) then Exit Sub else set to YES (1) and in the clear macro always set all to NO (0). This will allow the the text box to display ‘Eyes’ only once no matter how many times you click the button.

Hey Ratslinger, I got the issues with my last comment sorted out. I’ll give a detailed explanation of what I did as soon as I get a chance… many thanks

Sorry, I didn’t see that you had edited your original answer and modified your demo to address the issues I was asking about before I made my last comment. My son knows some VB, and we were able to get the strings concatinated although we did not change the string to global. I will definately digest the changes that you made to learn from them. In fact, I need to learn some LO basic myself to further my project. What would you say the best resource is to accomplish this?

The official LO documentation regarding their flavor of VB seems a little sparse. Thanks again for all your efforts. I would have never guessed in a million years that someone would be kind enough to actually write the macro for me. docbda

The document I use the most is OOME (Open Office Macros Explained) by Andrew Pitonyak. Easy to find with a search on internet. It’s overwhelming at first so don’t get discouraged. You might also find OpenOffice.org Basic Guide helpful. Learning macro coding takes a lot of time depending how deep you want to go. BTW, I only used global to keep it simple. There are always many ways to do things. It was my pleasure helping you.

@Ratslinger
The demo you postet does not compile because DrawPage is not a member of the object assigned to “doc”.
I don’t know if the devs changed something this intrinsic to their program, because it is in all the guides but it doesn’t work, neither on Linux nor on Windows.

@Nerobyrne The posted demo works without problems. You will get an error Property or method not found: Drawpage if the code is executed from the Basic IDE. The code needs to be executed through the Base form by clicking on the buttons.