using fields in a text document

PS

lee wrote (24-06-11 22:41)

When I click on such an input field, a dialogue box pops up allowing me
to enter what I want to put into the field. This is very much like just
deleting the text the input fields are replacing and entering the new
text.

Ctrl-Enter activates the OK button.

lee wrote (24-06-11 20:36)

So mailmerge is unfortunately broken, at least when using an LO
spreadsheet as a data source. I haven't tried to use something else
yet.

No, it works fine. At least in the way I use it :wink:

File > New > Database. Use the .ods as source.
Now you have a new Datasource.
(Also look at Tools > Options > Base .)

Type F4, open the datasource you created.
Drag fields (column headers) in your document (or use the window Ctrl-F2)

Now start Tools > Mail merge, and ... go immediately to step 8.

Close window F4, open and update your spreadsheet, F4 again ...

Cheers,

John B <johnb@email2.me> writes:

Dear Lee

Using my new found wealth of knowledge supplied be Tom - It looks
like:>> "this is how to do it"

http://www.libreoffice.org/get-help/documentation/

goto chapter 15 - "using Forms in writer" and it explains how to do it

you also have to turn on a tool bar for it (who knew)

View > toolbars > form design

I would be so pleased to know if you get this to work.

These forms don't seem to be very useful in this case: I have an already
finished document and only need a few text-items replaced. The forms are
made from graphical elements which may or may not align with the text in
the document.

The documentation[1] says:

Frieder <delorfr@googlemail.com> writes:

while(webpages) {

   check out the web page

   decide whether to send my document or not

   if(I send it) {
     create a new directory to save the document in // this is already
                                                    // automated by a
                                                    // shell script

     paste a unique reference number generated by the shell script into
     the document

     copy and paste some data like a company name and address and a
     persons name into the document

     adjust the salutation as needed

     go to another place in the document and enter the companys name and
     city

     save the document in the directory created by the shell script with
     a meaningful file name (like "<documentname>-<company>")

     export the document as pdf with a permissions password set

     create an email by editing an email template appropriately to send
     the pdf file by email

     save the webpage in the same directory as the LO document

     make a note in a text file that the document was sent in response to
     the particular web page
   }
}

I can hear this crying for (at least some more) automation from 10 miles
away ...

[...]

ther is a Basic example for a macro to export to PDF
its not clean code, but it should work:

[...]

if you want I can translate this code in clean code without using the
dispatcher

Hm, I just tried out the macro recorder and recorded a macro that
exports my document as PDF. It looks very much like the one you
posted. It even stores the permissions password I entered in readable
form.

It strikes me odd that I shall have to learn another programming
language to do something this simple ... Anyway, what bothers me the
most at the moment is this bug with all the fields disappearing from
data sources: Even if I don't enter more than one data set into a data
source through a form and some programming, I won't get anywhere when
the fields of the data source eventually disappear.

Hm. I can't even register a data source as described in the
documentation[1]. The only available selection the wizard offers is
"Other external data source", and selecting that and trying to get to
the next page of the wizard brings up an error message:

In news:87iprv49kt.fsf@yun.yagibdah.de,
lee <lee@yun.yagibdah.de> typed:

John B <johnb@email2.me> writes:

Hi Lee

Its called "mailmerge" you will love it.

Tools > Mailmerge

Please don't top-post.

The mailmerge tool requires an address list, which is
something I don't have and don't want to create in this
case.

Without a maling list "data file" you pretty much limit yourself out of a
very easy process. Somehow you've not been clear with your message or you
don't understand somethng IMO. Did you look at mailmerge in Help under
Writer?

HTH,

Twayne`

Cor Nouws <oolst@nouenoff.nl> writes:

lee wrote (24-06-11 20:36)

So mailmerge is unfortunately broken, at least when using an LO
spreadsheet as a data source. I haven't tried to use something else
yet.

No, it works fine. At least in the way I use it :wink:

File > New > Database. Use the .ods as source.
Now you have a new Datasource.

From there, when I select "Open an existing database file" and click on

the "Open ..." button and choose my spreadsheet ("mm-testdata.ods"), a
window pops up that says "Please choose 'Connect to an existing
database' to connect to an existing database instead." The pop-up has an
Ok button, and when I click that button, the pop-up disappears and in
the "Database Wizard" window, my selection changed from "Open an
existing database file" to "Connect to an existing database".

That's pretty confusing. There's a drop-down list, apparently listing a
number of ways to connect to a database and databases, among them
"Spreadsheet". In the following steps, I can finally select my
spreadsheet. When I click "Finish", I'm presented with a file selector.

That's very confusing. I already do have a file I want to use. I didn't
want to create a new database, which apparently is what I'm doing.

(Also look at Tools > Options > Base .)

Type F4, open the datasource you created.

Nothing happens when I press F4.

Drag fields (column headers) in your document (or use the window Ctrl-F2)

That's basically the same what I've already done by creating a new
database, filling in some test-data and inserting the fields into my
document in writer through Insert->Fields->Other. The result is a writer
document that has fields in it which refer to fields of a database.

Now start Tools > Mail merge, and ... go immediately to step 8.

That sometimes refuses to send mails, the window says "0 of 0 messages
sent" even when there are two mails to be sent. Sometimes it does send
mails. I checked the resulting PDF when it did send the emails, and it's
messed up:

The writer document includes some scans of documents I otherwise only
have on paper. When I export the document as PDF via the File menu,
everything is fine. When the mailmerge tool sends the PDF as email, some
of the scanned documents on the last page have moved up one page and sit
on top of the scanned document which is on that page. --- This is not
because the contents of the fields or the fields themselves would result
in the scanned documents moving to different pages. I can export the
document with the fields as PDF via the File menu, and the resulting PDF
is ok.

That's one bug turning up after another. Now I better check each PDF I
create page by page before mailing it out to see if it's messed up
because of some bug.

My next step will probably be to try to switch to LaTeX. And I have been
thinking that WYSIWYG word processing software has become more reliable
over the last 15 years because it doesn't crash as often as it used
to. Obviously, I am mistaken.

Close window F4, open and update your spreadsheet, F4 again ...

??

Hello Lee

Frieder<delorfr@googlemail.com> writes:

[...]

ther is a Basic example for a macro to export to PDF
its not clean code, but it should work:
[...]

if you want I can translate this code in clean code without using the
dispatcher

Hm, I just tried out the macro recorder and recorded a macro that
exports my document as PDF. It looks very much like the one you
posted. It even stores the permissions password I entered in readable
form.

Yes I also did it with the macro recorder, but I can translate it to better code if you want (the dispatcher is not reliable ).

It strikes me odd that I shall have to learn another programming
language to do something this simple ...

What programming languages do you know?
You can write macros in Basic, Python , JavaScript , and even in C, C++ ,Java and some more ,if you know how to call the Uno API .
But Basic is really simple. (No useless bracket for example. And how to write a " for loop " or something similar easy is not hard to learn in any language.)
The Problem is how to use the Uno API no mater programming language you prefer.

(...)

Hm. I have created a database to use instead of a spreadsheet. When I'm
trying to mail the document to myself as PDF, I can specify "Properties"
in the mailmerge wizard. There I could apparently add a text message so
that the PDF is sent as an attachment to it. I could use that to mail
the PDF documents to myself with the reference number in the text part
for easy further processing, or I might even be able to send them
without any further processing.

Unfortunately, LO crashes when I try to send the message:

,----
> X Error: BadMatch (invalid parameter attributes) 8
> Major opcode: 42 (X_SetInputFocus)
> Resource id: 0x5001822
> #
> # A fatal error has been detected by the Java Runtime Environment:
> #
> # SIGSEGV (0xb) at pc=0x00007f2cabeb5751, pid=21389, tid=139829845436192
> #
> # JRE version: 6.0_18-b18
> # Java VM: OpenJDK 64-Bit Server VM (16.0-b13 mixed mode linux-amd64 )
> # Derivative: IcedTea6 1.8.7
> # Distribution: Debian GNU/Linux unstable (sid), package 6b18-1.8.7-4

Have you tried it with a stable Version???

> # Problematic frame:
> # C [libuno_sal.so.3+0x43751] rtl_uString_release+0x1
> #
> # An error report file with more information is saved as:
> # /home/lee/hs_err_pid21389.log
> #
> # If you would like to submit a bug report, please include
> # instructions how to reproduce the bug and visit:
> # http://icedtea.classpath.org/bugzilla
> #
>
> [error occurred during error reporting , id 0xb]
`----

This seems to be Java problem, and not a LO bug.
regards
Frieder

"Twayne" <TWAYNE@TWAYNESDOMAIN.COM> writes:

In news:87iprv49kt.fsf@yun.yagibdah.de,
lee <lee@yun.yagibdah.de> typed:

John B <johnb@email2.me> writes:

The mailmerge tool requires an address list, which is
something I don't have and don't want to create in this
case.

Without a maling list "data file" you pretty much limit yourself out
of a very easy process. Somehow you've not been clear with your
message or you don't understand somethng IMO.

You're right in that I can't use the mailmerge tool without some sort of
list providing the data I need to insert into the document, since that's
the way the tool is supposed to work. If it would work, I could use it.

Cor Nouws <oolst@nouenoff.nl> writes:

lee wrote (24-06-11 22:41)

Is there another way to make LO ask for the contents of the input fields
than opening the document?

Ctrl-Shft-F9 (from my memory).

Cool, that works :slight_smile:

Is there a way to use the same input field several times or to refer to
an input field? What I mean is that I need some of the data I enter into
a field at two places in the document, so it would be useful if I'd have
to enter it only once. I tried to copy an input field, and it's the same
as adding a new one.

Steven Shelton <steven@sheltonlegal.net> writes:

I do *some* of that on a regular basis in my law office, since I send
out a lot of letters that are virtually identical ("Dear <TITLE>
<FIRSTNAME> <LASTNAME>, This letter is to remind you that your
<HEARING_TYPE> is scheduled to take place on <HEARING_DATE> at
<HEARING_TIME> before Judge <JUDGENAME> . . .").

What I ended up doing is just putting a blank page at the beginning of
the document where I list all the variables, then I just fill them in
there.

How exactly do you do that? I tried to find something about this in the
documentation without success.

Frieder <delorfr@googlemail.com> writes:

Yes I also did it with the macro recorder, but I can translate it to
better code if you want (the dispatcher is not reliable ).

Exporting to PDF has turned out to be unreliable in LO, too.

It strikes me odd that I shall have to learn another programming
language to do something this simple ...

The Problem is how to use the Uno API no mater programming language
you prefer.

True --- is there a good documentation about it?

Hm. I have created a database to use instead of a spreadsheet. When I'm
trying to mail the document to myself as PDF, I can specify "Properties"
in the mailmerge wizard. There I could apparently add a text message so
that the PDF is sent as an attachment to it. I could use that to mail
the PDF documents to myself with the reference number in the text part
for easy further processing, or I might even be able to send them
without any further processing.

Unfortunately, LO crashes when I try to send the message:

Have you tried it with a stable Version???

No, I only tried the version that is in Debian testing. Libreoffice is
not in Debian stable. LO 3.3.3 is in unstable. I could try to install
it, only it probably has so many dependencies that it isn't advisable.

> # Problematic frame:
> # C [libuno_sal.so.3+0x43751] rtl_uString_release+0x1
> #
> # An error report file with more information is saved as:
> # /home/lee/hs_err_pid21389.log
> #
> # If you would like to submit a bug report, please include
> # instructions how to reproduce the bug and visit:
> # http://icedtea.classpath.org/bugzilla
> #
>
> [error occurred during error reporting , id 0xb]
`----

This seems to be Java problem, and not a LO bug.

There seem to be two bugs, one with using the mailmerge tool and another
one with reporting the bug. Anyway, they shouldn't use java for LO.

It doesn't really matter what the problem is, it's just not working, and
one bug after another turns up. After having learned a little about LO,
it seems to be still in a beta stage, and I need something that does
work. It's sad that there has been only very little progress in the
reliability of WYSIWYG word processors over the last 15--20 years.

Frieder<delorfr@googlemail.com> writes:

Yes I also did it with the macro recorder, but I can translate it to
better code if you want (the dispatcher is not reliable ).

Exporting to PDF has turned out to be unreliable in LO, too.

do you men the Macro you produced with the macro recorder ?
The macro recorder uses the dispatcher, and the dispatcher is not reliable as I already mentioned.

It strikes me odd that I shall have to learn another programming
language to do something this simple ...

The Problem is how to use the Uno API no mater programming language
you prefer.

True --- is there a good documentation about it?

Yes there is:
http://wiki.services.openoffice.org/wiki/Category:Tutorial
and specially the export to pdf:
http://wiki.services.openoffice.org/wiki/API/Tutorials/PDF_export

Hm. I have created a database to use instead of a spreadsheet. When I'm
trying to mail the document to myself as PDF, I can specify "Properties"
in the mailmerge wizard. There I could apparently add a text message so
that the PDF is sent as an attachment to it. I could use that to mail
the PDF documents to myself with the reference number in the text part
for easy further processing, or I might even be able to send them
without any further processing.

Unfortunately, LO crashes when I try to send the message:

Have you tried it with a stable Version???

No, I only tried the version that is in Debian testing. Libreoffice is
not in Debian stable. LO 3.3.3 is in unstable. I could try to install
it, only it probably has so many dependencies that it isn't advisable.

maybe you should try another distribution like Suse, Fedora or Ubuntu (but don't try the Unity desktop its terrible. Use the XFCE desktop(Xubuntu) instead, it is similar to Gnome2 but much lighter and faster) .
The problem with Debian is, that the stable version is to old, and the testing and unstable is to unstable.

> # Problematic frame:
> # C [libuno_sal.so.3+0x43751] rtl_uString_release+0x1
> #
> # An error report file with more information is saved as:
> # /home/lee/hs_err_pid21389.log
> #
> # If you would like to submit a bug report, please include
> # instructions how to reproduce the bug and visit:
> # http://icedtea.classpath.org/bugzilla
> #
>
> [error occurred during error reporting , id 0xb]
`----

This seems to be Java problem, and not a LO bug.

There seem to be two bugs, one with using the mailmerge tool and another
one with reporting the bug. Anyway, they shouldn't use java for LO.

but there is still a lot of Java code in LO. They are working hard to translate it into C++ code, but it will take a while.

It doesn't really matter what the problem is, it's just not working, and
one bug after another turns up. After having learned a little about LO,
it seems to be still in a beta stage, and I need something that does
work. It's sad that there has been only very little progress in the
reliability of WYSIWYG word processors over the last 15--20 years.

The LO code contains about 6000000 lines of code. it is not easy to think of all the functions, if you ad some new code.
  So some bugs are unavoidable.

Regards
Frieder

I am with you on this (excluding Lotus Word Pro), frustration

I have tried the mailmerge facility in LO and I as yet cannot get anywhere with it.

Having got to "insert address block" which on my system is greyed out.

I have made a small data base > Select Address List > create

Then entered some dummy names and addresses, then click ok and saved as a csv file

  then clicked on the file name, then OK on the window box (which took a few clicks to appear - minor bug)

Then nothing - the Finish button is still greyed out - Big Bug

regards

John B

Frieder <delorfr@googlemail.com> writes:

Frieder<delorfr@googlemail.com> writes:

The Problem is how to use the Uno API no mater programming language
you prefer.

True --- is there a good documentation about it?

Yes there is:
http://wiki.services.openoffice.org/wiki/Category:Tutorial
and specially the export to pdf:
http://wiki.services.openoffice.org/wiki/API/Tutorials/PDF_export

Ah, thanks :slight_smile:

Unfortunately, LO crashes when I try to send the message:

Have you tried it with a stable Version???

No, I only tried the version that is in Debian testing. Libreoffice is
not in Debian stable. LO 3.3.3 is in unstable. I could try to install
it, only it probably has so many dependencies that it isn't advisable.

maybe you should try another distribution like Suse, Fedora or Ubuntu
(but don't try the Unity desktop its terrible.

No way, I'm not going to dump my perfectly working system just to be
able to run a more recent version of some software. I could probably
download the latest sources and compile them myself, but I don't feel
inclined to go to much effort to get a broken word processing software
to work. I'd probably only find either the same bugs or new ones.

The problem with Debian is, that the stable version is to old, and the
testing and unstable is to unstable.

That's not true. Stable can be old, and as long as it does what you need
it to, it isn't too old. Testing isn't unstable at all. I haven't tried
unstable or experimental except for a few packages every now and then I
needed a more recent version of.

Anyway, they shouldn't use java for LO.

but there is still a lot of Java code in LO. They are working hard to
translate it into C++ code, but it will take a while.

It's good to hear that they are working on removing it :slight_smile:

It doesn't really matter what the problem is, it's just not working, and
one bug after another turns up. After having learned a little about LO,
it seems to be still in a beta stage, and I need something that does
work. It's sad that there has been only very little progress in the
reliability of WYSIWYG word processors over the last 15--20 years.

The LO code contains about 6000000 lines of code. it is not easy to
think of all the functions, if you ad some new code.
So some bugs are unavoidable.

It comes down to that beyond a certain point, the effort that needs to
be put into making it easier to achieve a particular result exceeds the
effort that must be put into achieving the particular result. In this
case, unfortunately I've reached that point.

John B <johnb@email2.me> writes:

I have tried the mailmerge facility in LO and I as yet cannot get
anywhere with it.

Hm, it's not too difficult to get to the point where you could finally
save, print or send your documents. Just make sure that there are no
unmatched fields. As someone described, you can even drag and drop
fields from a database into your document.

I could use mailmerge if it would reliably send the documents rather
than sometimes say "0 of 0 messages sent" despite there are two messages
to be sent --- and if the PDF created that way wasn't messed up. And it
would even be really useful if changing the "properties" when sending
documents as PDF would work rather than crash LO.

Hi :slight_smile:

It might be a good time to file a bug-report about the pdf properties issue
http://wiki.documentfoundation.org/BugReport
Regards from
Tom :slight_smile:

Hi Lee

John B<johnb@email2.me> writes:

I have tried the mailmerge facility in LO and I as yet cannot get
anywhere with it.

Hm, it's not too difficult to get to the point where you could finally
save, print or send your documents. Just make sure that there are no
unmatched fields. As someone described, you can even drag and drop
fields from a database into your document.

I could use mailmerge if it would reliably send the documents rather
than sometimes say "0 of 0 messages sent" despite there are two messages
to be sent --- and if the PDF created that way wasn't messed up. And it
would even be really useful if changing the "properties" when sending
documents as PDF would work rather than crash LO.

If you are still interested in a reliable macro that can export to PDF with a password I have coded some lines for You: (StarBasic code)

sub export_pdf_with_password

odoc=ThisComponent.CurrentController.Frame
sURL = "file:///C:/Users/Nansen/Documents/RundschreibenTest0096.pdf" 'variable to hold the Path

dim args1(5) as new com.sun.star.beans.PropertyValue
'args1(0).Name = "UseTaggedPDF"
'args1(0).Value= true

args1(0).Name = "ExportFormFields" 'just schow the contens of the Form.Filds
args1(0).Value= false
args1(1).Name = "Printing" ' you don't need that.
args1(1).Value= 2
args1(2).Name = "RestrictPermissions" 'If true, selects to restrict some permissions. The permissions can be changed only when the user enters the correct password.
args1(2).Value= true
args1(3).Name = "PermissionPassword"
args1(3).Value= "www2" 'coud be a variable
args1(4).Name = "EncryptFile" 'If true, selects to encrypt the PDF document with a password. The PDF file can be opened only when the user enters the correct password.
args1(4).Value= true
args1(5).Name = "DocumentOpenPassword"
args1(5).Value= "www" 'coud be a variable

'here you can enter some more options from the " http://wiki.services.openoffice.org/wiki/API/Tutorials/PDF_export " if you want

dim args2(2) as new com.sun.star.beans.PropertyValue

args2(0).Name = "FilterName"
args2(0).Value = "writer_pdf_Export"
args2(1).Name = "FilterData"
args2(1).Value = args1

thisComponent.storeToURL(sURL,args2())
end sub

I have done a complete solution for your hole problem (not totally complete jett). I used a database (instead of a Calc file) .
I can send the solution to you but I think you have to reconnect the Writer-document and the Database on your computer.

Regards Frieder

Hi :slight_smile:
I have been wondering about trying to run a more stable version of LO on
Debian. Can Debian run PPA repos from Ubuntu? or is that a bit hit&miss due to
differences within the Debian family? Even if you are not able to get the 3.3.3
or 3.3.2 from the Debian repos the untweaked debs from the LO/TDF website might
be an improvement on what you have now. There are instructions on the wiki for
installing more than 1 version of LO/OOo at a time so that you can test without
throwing away anything that you have set-up so far. I don't know if that is a
good route tho?
Regards from
Tom :slight_smile:

Hi Lee,

If you want to look at using Python, try using the example
TableSample.py and mailmerge.py which are included with your LibreOffice
installation.

Otherwise, there are several PHP classes and a PERL module that let you
manipulate ODT/ODC documents to your heart's content. I mean if you are
going to script your work and you don't want to learn Basic, you at
least have several other ways of attaining the same objective.

Alex

I rarely use fields in this way, but, I believe that the proper term is "master field". As long as you use a text field that is a child of a master field, all children for that field should reference the same value. I hesitantly state this without providing a working example, but, I thought that the information may be useful regardless.