Reference .dot Template file automatically from .doc file

I have a workflow in Word97, which makes use of VBA-macros to load a menu-item, which then shows a bunch of entries upon clicking which, it inserts specific text into the existing document. The template file itself loads fine in LibreOffice Writer (7.1), and also inserts text into the editor. Problem comes, when I try to open it as referenced from the .doc files. The macro doesn’t load. However, I was able to embed the VBA classes from MS-Word Macro Organizer:

After this I set, AutoExec as my Startup Event Macro in LibreOffice Writer:

image description

This at least allows the macro code to be still present in the document, and could be invoked on startup.
This however has following problems:

  1. It is no longer maintained at one place, and is a maintenance nightmare.
  2. Causes code replication and extra document bloat.
  3. Most important, code no longer works, I need to fix it to even get it to run: Why? It ran fine when in .dot format.

How do I get the .dot file to load as in original workflow in MS-Word, in LibreOffice?

(reformatted by ajmittoz)

Writer is not Word and was never intended to be a drop-in replacement for it.

Founding principles are different. Styles are ubiquitous (and much more consistent than in Word).

Switching from Word to Writer requires adaptation, all the more when templates are involved. Templates for Writer are .ott files. Don’t expect VBA macros to work under LO because the Basic dialect is not the same and, most important, tha API for the application is radically different.

From experience, at least 75% of Word macros betray a lack of knowledge of available features. This is particularly true in Writer.

Without description of your ultimate goal (what is this text insertion for? in which context? …), it is impossible to give targeted advice.

Don’t use an answer (this is a Question & Answer site, not a forum). Answers are reserved for solutions.

Please do not use Add Answer but edit your original question to enhance the details of your question (answers are reserved for solutions to a pro

Thanks for reformatting, I was struggling with newline. My workflow is:

  1. There is a bunch of ‘Report Templates’, which might contain specially formatted strings, for particular fields. These ‘Report Templates’ are then used by a C# application which then uses these to generate actual ‘Reports’ which then have the respective values for these strings, looked up from Database, and then substituted, into the new resultant ‘Report Document’.

  2. The macro is for editing ‘Report Template’ documents.
    Consider for example: There might be ‘Student Report Card’, ‘Student Co-Curricular History’, etc. Templates, which have the same layout. So, consider them as analogous to ‘Report templates’. Particular fields, like ‘Name’, ‘Grade’, etc might be represented by field Identifiers like ‘Nm’, ‘Gr’. Upon parsing these field strings from the templates, these are looked up on a record-basis from the Database, and substituted, for say ‘Amit’, ‘A+’, etc.

Unless needed, do we need to look at code?

From the description in your comment, I think you chose a wrong workflow.

I assume your data is stored in some database. In its simplest form this “database” may be a spreadsheet. It can also be a real database hosted by SQLite, PostgreSQL, MariaDB (only to quote free engines).

With the simplest “DB” and simple report templates, you can use the mail merge function of Writer. No need of macros for that.

With traditional DB or more complex templates, the Base component (=application) of LO is your friend. You define queries to retrieve needed data from the DB and you design report templates directly in Base to display the query result. Reports can be generated in a variety of formats, of course Writer .odt but also PDF and others.

Since design can be done graphically, it will be much easier than trying to translate your M$ macros.

To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

In case you need clarification, edit your question (not an answer which is reserved for solutions) or comment the relevant answer.