Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

add button to libreoffice calc

Posted on 2013-12-21
3
Medium Priority
?
2,179 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
Viewers will learn how to customize the ribbon and quick access toolbar in Excel 2013.
Viewers will learn various types of data validation for different data types in Excel 2013.

885 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