[Solved] Insert text from external file when opening a file

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Apaco
Posts: 3
Joined: Fri Aug 22, 2008 2:22 am

[Solved] Insert text from external file when opening a file

Post by Apaco »

I would like to do the following:
Create a document that contains a company letterhead; name, address, phones. Basic centered text.
Create many reusable documents that, upon opening, insert the contents (with formating) of the letterhead document at the top of the opened document.

The idea is to be able to modify the letterhead document and have that letterhead show up each time the prefabricated documents are opened.

I am not a programmer (a hangman program in Pascal MANY years ago) but I've been trying to piece together the bits and pieces from this site and may others to try and get it to work with no luck. I have working examples from M$ Word using a .doc file for the letterhead and the prefab documents call a .dot file when opening to insert the test from the .doc file. I have also downloaded Russ Phillips 'Combine Files' http://voxel.dl.sourceforge.net/sourcef ... es_1-1.zip macro for OOo but I cannot figue out how exactly to modify it to do the above.

Any assistance would be greatly appreciated.
Last edited by Apaco on Fri Aug 22, 2008 7:37 pm, edited 1 time in total.
OOo 2.4.X on Ms Windows XP
User avatar
TheGurkha
Volunteer
Posts: 6482
Joined: Thu Mar 13, 2008 12:13 pm
Location: North Wales, UK.

Re: Insert text from external file when opening a file

Post by TheGurkha »

What about creating a 'letter-head' template and, as and when required, basing your new documents on that template? These new docs would have the letter head details in them as soon as they were opened and you could then compose your document as you see fit. Docs that you don't want to have any details in you could just base on the Default template.

Unless I've missed something (eminently possible) I don't think you need to get complicated to achieve this.
Ubuntu 14.10 Utopic Unicorn, LibreOffice Version: 4.3.3.2
Gurkha Welfare Trust
Apaco
Posts: 3
Joined: Fri Aug 22, 2008 2:22 am

Re: Insert text from external file when opening a file

Post by Apaco »

Thanks for your reply.
This is not intened for creating new documents but updating a section of previously created documents. The goal is to be able to change the letterhead in a single document and have that updated letterhead show up in all the previously created documents when they are opened.
OOo 2.4.X on Ms Windows XP
User avatar
TheGurkha
Volunteer
Posts: 6482
Joined: Thu Mar 13, 2008 12:13 pm
Location: North Wales, UK.

Re: Insert text from external file when opening a file

Post by TheGurkha »

Ah. OK, let me think about that.
Ubuntu 14.10 Utopic Unicorn, LibreOffice Version: 4.3.3.2
Gurkha Welfare Trust
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Insert text from external file when opening a file

Post by acknak »

A template can supply new/updated styles to existing documents, but not content.

However, you can insert a graphic (e.g. a logo or letterhead) as a link to a separate file. If you later change the contents of the file pointed to by the link, then the appearance of the document will change also, without having to modify the document.
AOO4/LO5 • Linux • Fedora 23
Apaco
Posts: 3
Joined: Fri Aug 22, 2008 2:22 am

Re: Insert text from external file when opening a file

Post by Apaco »

Many thanks and sorry for (ending up) posting in the wrong place.

FYI to those with the same requirements, while playing with inserting an OLE object I found that my "letterhead" document had to be saved as a .DOC and not a .ODT. The .ODT added close to half a page of white space below the end of the text in the letterhead file. I also found (but have not really dug too deap into it) that I had to save the resulting file as a .ODT file. After saving as a .DOC, when re-opening the file for verification, the inserted OLE object had been turned into a picture so updates to the letterhead document were not reflected.

By the way...Windows Server 2003 R2 with OOo 2.4.1

Thanks again!
OOo 2.4.X on Ms Windows XP
User avatar
TheGurkha
Volunteer
Posts: 6482
Joined: Thu Mar 13, 2008 12:13 pm
Location: North Wales, UK.

Re: Insert text from external file when opening a file

Post by TheGurkha »

Glad you got it sorted.

If your question has been answered please go to your first post, use the edit button and add [Solved] as the first word of the title. You can also select the green tick icon.
Ubuntu 14.10 Utopic Unicorn, LibreOffice Version: 4.3.3.2
Gurkha Welfare Trust
Post Reply