Solved

add button to libreoffice calc

Posted on 2013-12-21
3
1,828 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
Comment Utility
0
 
LVL 20

Accepted Solution

by:
ltlbearand3 earned 500 total points
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This document is written for Red Hat Enterprise Linux AS release 4 and ORACLE 10g.  Earlier releases can be installed using this document as well however there are some additional steps for packages to be installed see Metalink. Disclaimer: I hav…
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 …
Viewers will learn how to apply various conditional formatting in Excel 2013.
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now