Solved

add button to libreoffice calc

Posted on 2013-12-21
3
1,989 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

After running Ubuntu some time, you will be asked to download updates for fixing bugs and security updates. All the packages you download replace the previous ones, except for the kernel, also called "linux-image". This is due to the fact that w…
This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
Viewers will learn how to find and create templates in Excel 2013.
Viewers will learn how to create a PivotTable and make basic changes to it in Excel 2013.

738 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