Ask Your Question

Base macro transfering text from Word Doc to Textbox [closed]

asked 2017-08-10 11:03:16 +0200

meakasteve gravatar image

updated 2017-08-10 23:04:43 +0200

Recently the question was asked How do I open a Word document from a Base macro? The solution given works wonderfully but how should the code be altered so that the text will appear in a scroll textbox on the form?

To be specific: I'm trying to get the text contained in a writer document into a text box of a database. The idea is to use the text box as a 'Help' guide, giving an inexperienced user of the database information about what the various buttons etc on the form that he/she is presently looking at, do. The text for each particular form would be held in a separate writer document and its contents would be displayed by the macro when the relevant form is opened. The previous solution mentioned above displays the whole document in a separate window rather than having it displayed on the form itself and is therefore inconvenient as a 'Help' text. But the advantage of having the text on a writer file rather than embedded in the macro lies in the convenience with which the text could be modified and maintained.

I have written a macro that gets a text explicitly quoted within the macro into the box (hardly, I agree, a great feat!) and I know how to connect the macro with the open (Base) document event. What I still need to do is to capture the raw text from the writer document and insert it into my Base macro which then puts it into the text box. I think the problem is that I have no idea about writer macro commands. My hope is that someone well-conversed with macros for writer can help me. My present project is developing a rather complex database and I would appreciate any help on, at least for me at the moment, the 'fringe' topic of writer macros!

Bottom Line: I am hoping that someone on the forum can share with me the couple of lines of script that illustrate how to grab the text from the document. With that clue I hope that I can write the the rest of the code.

If you can help I would be most grateful.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-10-12 19:56:03.676886


Your question is not clear on what you are attempting. Exactly what text are you talking about? Is this something from Base to Writer? What have you tried that doesn't work? What code are you using? I hope you are not using this forum to get people to write code for you. Have you checked documentation?

Ratslinger gravatar imageRatslinger ( 2017-08-10 19:50:37 +0200 )edit

Hi Ratslinger! First my profound apologies. After uploading my question I thought it might be seen as rather curt. (I always fear being verbose!) Your reaction is understandable and as a result I have expanded my question in response to your justified criticism.

I hope that you see that my intentions are not to have anyone write code for me but only to ask the forum, as a person relatively new to LO macro programming, for advice where to look in the documentation.

meakasteve gravatar imagemeakasteve ( 2017-08-10 22:33:40 +0200 )edit

"I have written a macro that gets a text explicitly quoted within the macro into the box"

please post the macro that you have written already.

librebel gravatar imagelibrebel ( 2017-08-11 00:36:17 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2017-08-10 22:34:35 +0200

Ratslinger gravatar image

updated 2017-08-10 22:36:33 +0200

@meakasteve Thank you for a better description of the situation. I have worked a bit with writer documents and macros but not enough to confidently help in this matter. An excellent source for this would be OOME (PDF here).

It does seem to me to be a difficult way to go having to maintain many different documents and also that they be available with Base. Have you considered using another table to store and maintain the information? Your macro can easily recall specific information based upon a naming convention using SQL then paste the data where appropriate. The actual table doesn't need to be shown on the main base display. From menu, Tools->Table Filter.. allows what tables to show.

Just a thought.

edit flag offensive delete link more


I had not thought of a SQL/Table solution but I think the idea is great and well worth pursuing. Elsewhere in my database I am writing script that will produce a "grocery" list by selecting various items from a table. It seems a sensible strategy to complete that task first and then see if those techniques can be employed for this problem. For the present therefore my question is answered. If I do return to it in the future I shall not forget the 'writer' tag missing this time!

meakasteve gravatar imagemeakasteve ( 2017-08-11 12:17:29 +0200 )edit

@meakasteve To help with some direction in my answer here is some code for running SQL in basic. I know I have many other samples posted, but I found this one first.

Your questions are always welcome here.

Ratslinger gravatar imageRatslinger ( 2017-08-11 15:05:55 +0200 )edit

Question Tools

1 follower


Asked: 2017-08-10 11:03:16 +0200

Seen: 97 times

Last updated: Aug 10 '17