The application I'm working on outputs documents to rtf format and PAGEREF fields are used in a table of contents page and an index page. The problem is that on opening the document the fields do not update and remain blank. They work correctly if you manually update the fields in Word. Is there a way to make these fields auto-update in the RTF spec?
You could try to create a Document_Open() macro, although you might not be able to add a macro to an rtf file. You might be able to add a macro at a template (.dot) and have the .rtf file reference the template.
Private Sub Document_Open()
End Sub
Related
I am writing a Macro programm in a LibreOffice Calc spreadsheet. This macro should do the following (amongst other things):
open an existing ODT text document as a template
search and replace some strings with new values
save a copy of this as a new file
generate and open a PDF version
Is this possible somehow using LibreOffice Basic only? I have found nothing in the Libreoffice docs and examples and only this slightly related answer here on SO: How to programatically modify Open/Libre Office odt document?
Thanks!
open an existing ODT text document as a template
The method to open a document is loadComponentFromURL, for example https://help.libreoffice.org/6.4/en-US/text/sbasic/shared/stardesktop.html. There is nothing especially difficult about opening a document in Writer from a Calc macro, as LibreOffice components are well integrated. Remember to use the object returned from opening the document instead of ThisComponent.
search and replace some strings with new values
Andrew's Macro Document section 7.14. Search And Replace shows some ways to do this.
save a copy of this as a new file
The command is storeAsURL which is like "save as", not to be confused with storeToURL which would modify the existing file. See https://wiki.openoffice.org/wiki/Saving_a_document.
generate and open a PDF version
Generating a PDF is like any other save. The only difference is that the export filter writer_pdf_Export must be specified. An example is at https://ask.libreoffice.org/en/question/178818/how-i-export-pdf-using-macro/.
As for opening the PDF, what application do you want to open it? LibreOffice Draw can open a PDF although it's not a normal PDF viewer. Shell can call the viewer of your choice.
This is in an IDTExtensibility2 (not VSTO) Word AddIn. I'm trying to do a drag drop where I programatically give the contents of one document to DoDragDrop(). The problem is instead of dropping the contents in the other document, it inserts it as an embedded Word document.
My code is basically:
srcDoc.Activate();
activeWindow = srcDoc.ActiveWindow;
selection = activeWindow.Selection;
selection.WholeStory();
selection.Copy();
data = Clipboard.GetDataObject();
DragDropEffects effect = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Scroll);
How can I have it paste the contents instead of pasting the document?
Please note, I want to paste all of the content in the source document into the insertion point of the drop in the destination object. So it's not copy over the full contents of the destination (therefore a file based approach won't work).
And it's drag/drop so I don't have the control that Clipboard.Paste() provides to specify the pasting format. In addition, the format I need is the native DOCX format to bring all properties & formatting across.
thanks - dave
Is it posible to import a BibTex library in Libre Office Writer?
I have a BibTex file that was generated with BibDesk and which I woul like to import in Libre Office.
Yes BibDesk can export to .doc (libre can import .doc) and many other formats. You can aslo modify the formats
Ref sourceforge SEC117
Export Templates
Templates allow you to export your database to a large variety of formats. It also allows you to customize to a great extent how the data is exported.
To export using templates, choose the "Export..." menu item, which can be found under the "File" menu. You can choose the template from the "File Format" popup button. You can either export the whole database, or just the references which you have selected.
BibDesk provides several default templates, for export to HTML, RSS, Rich Text (RTF, RTFD) and to windows Doc format.
You can also modify a template
Bibdesk Templates
You can find a set of default template files in the folder ~/Library/Application Support/Bibdesk/Templates. For HTML export, there are 3 template files: htmlExportTemplate.html, htmlItemExportTemplate.html and htmlExportStyleSheet.css. Generally, only the first of these template files is required
Looking at the htmlExportTemplate.html file first, this is a relatively simple html document, with a standard header, a link to the external CSS file, and a single "content" div in the body. The formatting of the individual entries into the html file is done using the htmlItemExportTemplate.html file. Opening this file, you will see that the template files comprise a series of items enclosed in < and > signs, the same as those used in HTML to enclose formatting tags, but starting with an extra $. These entities are known as Template Tags.
They are parsed by BibDesk to include the relevant parts of the BibDesk database in the html file. E.G. will be replaced by the contents of the "Title" field in the BibDesk database. A list of the different kinds of Tag is given in the Export Template Keys page. It is also possible to apply modifiers to the field Tags in order to format the contents. One example is the Tag where the full name or an abbreviated name can be chosen, and the "and"s between authors can be replaced by commas. These modifier keys are also explained at the Export Template Keys page.
I hope this helps
I want to automate some writer tasks. I need to create a .odt writer
document with oo:doc using methods such as create paragraph and append
paragraph. The problem is that append paragraph and create paragraph does not
allow text to start at middle of page or at a certain column, ie
Name Surname Address
When I unzip the "master" document I want to to create, when I inspect the content.xml file i see the xml equivalent is
" <text:p text:style-name="Text_20_body"><text:s text:c="115"/><text:span text:style-name="T1"><text:s/>Hallo how are you today</text:span></text:p><text:p text:style-name="P1"><text:s text:c="116"/>I hope you are well also</text:p><text:p text:style-name="P1""
How do I set the text:c and text:s element(s) from within oo::doc
Question2:
How do i set the formatting of a paragraph
to only extend from ie column 20 to column 80
thanks
Those elements are for runs of non-breaking spaces. the text:c attribute says how many spaces there are.
That doesn't strike me as a solution to what you want, which is to change the margins and position of a paragraph, yes?
Do you have a document that you want to use as a template, where the text will be inserted? Or ar you trying to create the entire page from scratch?
I think you want to use OpenOffice.org to create a Writer document that has the structure you want, then look at the XML to see what the markup is that accomplishes that. Look at paragraph-level styles or even frames if that is what is used. You might be able to create insertion points for your generated content by then adding magic-text phrases that you can scan for.
Then figure out how to get that done with the perl module.
I have a crystal report which contains a list of absolutely referenced text files. There is one text file referenced in each body line.
e.g.
line1 c:\file1.txt
line2 c:\file2.txt
Is there any way to display the contents of these files in Crystal?
i.e. I would like each crystal body line to show the text from the referenced text file.
I'm using Crystal reports 11 with a non-standard database connector (dataflex).
You would need to set up a file dsn (in XP it's under Control Panel/Administrative Tools/Datasources (ODBC)) and then use the file dsn (Microsoft Text Driver) for the datasource as an ODBC(RDO) connection.
I set this test scenario up on mine like the following:
**File 1**
column1
1row1
1row2
1row3
**File 2**
column1
2row1
2row2
2row3
I set up the file dsn to point to the c drive and in the datasource screen I added file1.txt and file2.txt to the selected tables. Then the easiest thing to do is clear the links of the tables so that it pulls every row. It will warn you that there are multiple starting points. I don't generally recomend this, but it will work in this case and since it's not reporting off a database it probably isn't the end of the world. If you disregard the starting point message then add the fields to the report, when you run it you should get the following output:
1row1 2row1
1row1 2row2
1row1 2row3
1row2 2row1
1row2 2row2
1row2 2row3
1row3 2row1
1row3 2row2
1row3 2row3
From this you can change your grouping to get the output that you need.
You can also use this same connect against subreports instead of doing this linking where you have the main report pull the info from file1.txt and then put a subreport in the report footer that pulls from file2.txt. This option won't have the text collated, but you'd still have it in the same report.
Hope this helps some.
It's easier than you think. I just set up one myself before I wrote this to make sure I was giving you the right steps. Using CR version XI and a .txt file, I followed these steps:
For each text file you want to import, make a subsection in your report (i.e. DetailsA, DetailsB, etc.). If your list of text files is constantly changing (and I don't think it is, based on your description), you'll need another method.
Make sure your text file is comma delimited and the first row contains field names. If these text files are actually text (i.e. not tables), then just put a dummy variable name in the first row so Crystal will see the text as a table of data with just 1 row.
For each text file you want to display, create a new Subreport (Insert->Subreport)
In the database selection menu, go to "Create New Connection"->"Access/Excel (DAO)"
Under 'database type', you'll see a 'text' option at the bottom of the screen.
Choose your file.
Relax! (I'm in a good mood this morning, don't know why)
I guess if you have a function that takes a file name as an argument and returns the contents of that file - you could use that function in a Crystal Report formula.
I am not familiar with the current CR, it has been years since I last used it (I last used version 8). In the versions I did use, such a function was not built in. What you would have to do back then, was to create a UFL (user function library) containing the functions you needed. If I remember correctly, you had to do this using COM.
In this day and age, I guess you can extend CR using some other mechanism, perhaps writing .NET code?
I suggest you search the CR documentation for the term UFL.
Another suggestion, then:
Create a new table FILECONTENTS (filename varchar primary key, contents blob)
Create a script that on a schedule populates this table with the filenames and contents of all the files (assuming that there is a finite number of files, and that you have a way of knowing about them)
Modify the report datasource query to join it with the FILECONTENTS table, and add the contents field to the report.
You could setup a file dsn. But this is geared toward tabular file data, not text.
How big are these text files? You want to display the entire contents of each file?
There is probably no easy way to dynamically read in a file from within crystal. You will most likely have to push a dataset to the report which contains the file contents.