Macro to add pictures to document?

Help with installation and general system troubleshooting questions concerning the office suite LibreOffice.

Macro to add pictures to document?

Postby RhinoCan » Sun Dec 11, 2016 5:39 pm

I am working on a project in which I hope to add a large number of photographs to a document. The document will essentially contain a photograph on each page and each photograph will have a caption. I'm looking to make the process of building the document as efficient as I can. Is it possible to write a macro that essentially processes an entire folder of photographs and puts each photo in the folder on a new page, resizes it so that it fits comfortably on the page, and adds a placeholder caption to that photograph? If I could do that it would save me a great deal of manual labour. Then, I can simply replace each placeholder caption with a real one, then add my own comments, where warranted, below the caption.

Although I have programming skills and have worked with several programming languages, including Basic and Java, I've never had much occasion to work with macros. I suppose I know the main concepts but that's about it. If someone could tell me that it's possible to do what I'm proposing and maybe write a bit of pseudocode to give me an idea how it would look - or point me to an existing example - that would be VERY helpful!

Even a macro that simply added one picture with a placeholder caption to a single page would be helpful if it isn't possible (or easy) to do an entire folder in one go.
OpenOffice 4.1.2 and Libre Office 5.2.3.3 on Windows 10
User avatar
RhinoCan
 
Posts: 80
Joined: Fri Jun 10, 2011 11:36 pm

Re: Macro to add pictures to document?

Postby Villeroy » Sun Dec 11, 2016 6:15 pm

What you describe is a database report. Works without macros. With LibreOffice you don't even need any extensions. OpenOffice users need to install http://extensions.openoffice.org/en/pro ... rt-builder in order to get pictures on report pages.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 29294
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Macro to add pictures to document?

Postby Villeroy » Sun Dec 11, 2016 9:23 pm

Example: https://forum.openoffice.org/en/forum/d ... hp?id=8790
Replace the odb document with the attached one. I've added a report. Unfortunately I don't know how to insert a page break for each record.
Attachments
HSQLDatabase.odb
Modified database for picture_links.zip
(69.15 KiB) Downloaded 144 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 29294
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Macro to add pictures to document?

Postby RhinoCan » Tue Dec 13, 2016 4:41 am

Thank you for your quick replies to my question, Villeroy, but I have to confess that I don't understand them. How does putting the pictures in a database help? Don't get me wrong, I'm a database guy and have worked with them a lot over the years: I just don't see how they aid in accomplishing my project.

I would be happy to accomplish my goal with or without macros; it really doesn't matter to me as long as the job gets done. I would be quite willing to use a database too. I just don't see how it helps me. In fact, it seems to be an extra step: first I have to get all the photos into a database, which is far from trivial, then I still have to pull them out somehow and add them to my document. They are already sitting in a single folder that should be accessible to LibreOffice in some way.

I looked at the example you provided but I couldn't get the database to open. Then I looked at the first page you linked and it was full of remarks to the effect that the database extension was buggy and even outright unusable. That didn't fill me with confidence!

Is there no way to automate the process of clicking on the Image icon, selecting a photograph, and adding a placeholder caption? That doesn't seem like it should be hard but maybe it is beyond the capabilities of LibreOffice....
OpenOffice 4.1.2 and Libre Office 5.2.3.3 on Windows 10
User avatar
RhinoCan
 
Posts: 80
Joined: Fri Jun 10, 2011 11:36 pm

Re: Macro to add pictures to document?

Postby Villeroy » Tue Dec 13, 2016 10:43 am

There is no picture in my database. The file names of pictures are read from a text file. The text file had been created with a simple shell command. So the form's list box reads file names from a linked text table which reads the availlable file names from a text file. From the list box you pick a file name and store it in the actual data table. The form's picture control shows the picture that is stored in the respective file. The report has the same type of picture control which is linked to a field of file names relative to the database document.

Of course you can leave out the form which is related to another topic about associating pictures to records. You can easily generate a database report for all pictures in a directory. You don't even need any database. You can connect a Base document to csv files and to spreadsheets. But a true database connection has a lot of advantages.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 29294
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to LibreOffice

Who is online

Users browsing this forum: No registered users and 1 guest