Solved

add button to libreoffice calc

Posted on 2013-12-21
3
1,940 Views
Last Modified: 2013-12-22
I'm using libreoffice calc in ubuntu. Can I add a button to open a file I always open?
0
Comment
Question by:dwcronin
3 Comments
 
LVL 18

Expert Comment

by:TobiasHolm
ID: 39733789
0
 
LVL 20

Accepted Solution

by:
ltlbearand3 earned 500 total points
ID: 39733893
To open a specific file each time you click a button, you will need to add a Macro to process the steps when a button is clicked.  Here is how you can do that.  [I have a Windows box, but these steps should be the same for Ubuntu]

Open a blank calc document
Go to Tools >> Macros >> Organize Macros >> LibreOffice Basic
Expand My Macros
MarcoWindowClick on Standard
Click New
Put a name in macro name like DefaultOpenFile
Click OK

Paste this code into the code window that opens.
Make sure you change the file name in path of the variable strDefaultFile so that the file you want to open will open.
' ExpertExchange Question ID 28323668
' http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/Star_OpenOffice/Q_28323668.html
' Expert: ltlbearand3 [http://www.experts-exchange.com/M_2469312.html]
'
' Libre Office Basic Code to Open File

Sub OpenDefaultFile
    ' You will want to update this string with the path and File name you want this code to open
    strDefaultFile = "E:\EETest\test.ods"
    strStartUpURL = convertToURL(strDefaultFile)
    objStartUpFile = StarDesktop.loadComponentFromURL(strStartUpURL, "_blank", 0, Array())

End Sub

Open in new window

Click Save.

Now we can assign this Macro to a specific button so that when you click that button, this code will run.
Go to Tools >> Customize
Under Toolbar content Click Add
Scroll down to the category of LIbreOffice Macros
Expand
Expand My Macros
Expand Standard
Click on DefaultOpenFile (or whatever you named it)
In commands click on OpenDefaultFile
Click Add
Click Close
Here you can click modify to change the button some.

Now you will have a button to open you file.  Let me know if you have any questions.

-Bear
0
 

Author Closing Comment

by:dwcronin
ID: 39734920
Obviously, I changed the backslashes to forward slashes in my path since I use Ubuntu.  OBVIOUSLY  I was wrong.  I changed back to what you had and your code works fine.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Guacamole cut and paste issue 3 95
Expand a partition in Centos 7 Linux with Virtualmin 1 68
Truecrypt and swap 6 139
Excel 2010 - Formula to determine a part of the range 2 32
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Viewers will learn what comprises a theme in Excel 2013, as well as how to customize them.
Video by: Zack
Viewers will learn about various customizable options in Excel 2013.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question