Solved

add button to libreoffice calc

Posted on 2013-12-21
3
2,042 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Users are often faced with high disk consumption without really knowing where the largest amount of data resides. Disk Usage Analyzer (aka Baobab) is is a graphical, menu-driven application to analyse disk usage in any Gnome environment and can e…
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
Viewers will learn what comprises a theme in Excel 2013, as well as how to customize them.
Viewers will learn how to create a PivotTable and make basic changes to it in Excel 2013.

627 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