Ask Your Question
1

Can't save LibreOffice Basic Macro in .xls file [closed]

asked 2012-02-28 20:35:35 +0100

sophos7 gravatar image

updated 2015-10-20 13:41:34 +0100

Alex Kemp gravatar image

I'm not sure if this is a limitation of .xls format or a bug/missing feature. I know that macros are considered experimental at this point, but here's my problem.

If you create a macro in Libre Calc and save the file as an .xls (97/2000/XP/2003) format, the macro will not save to the file. This has been tested on 3.4.5 and 3.5.0rc3

I open or create a new .xls file. I record a macro and save it to the document. I am able to run the macro while still in the document. As soon as I close the document and open it again, the macro is no longer listed.

If I save the spreadsheet as .ods the macro saves properly.

I'm also able to create a simple macro in Excel 2010 and save the file as .xls. When I open with Libre Calc the macro is listed and I can run it without issue.

Again, is this a limitation of .xls or is Libre not saving the macro because of a bug?

Thanks, Shawn

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-10-20 13:42:19.142277

2 Answers

Sort by » oldest newest most voted
0

answered 2012-03-01 23:27:27 +0100

TonyP gravatar image

From what I can gather from the Help, you cannot save macros in LibreOffice Basic to a MS Office file format. If you load a MS Office Word or Excel file, and you have the default settings in Tools > Options... > Load/Save > VBA Properties, LibreOffice will keep the VBA (Visual Basic for Applications) code and restore it to the MS Office format when you save it. See what the Help text says for Load/Save > VBA Properties.

I am quite surprised that you say that simple Excel macros will run. Perhaps someone else can comment on that.

edit flag offensive delete link more

Comments

Thanks, I wasn't able to find this in help. I only found how to enable experimental features and to allow VBA to run in Libre. Somewhere in the help it says that some VBA code will work in Libre. The syntax of Basic is the same as VBA but object names are different.

sophos7 gravatar imagesophos7 ( 2012-03-02 18:21:22 +0100 )edit

I use LO in Ubuntu Linux which has built in Help. I believe the Windows version uses on-line help called up in your browser. There is an option to load the VBA from a MS document and have it held and saved back if you save in MS format. However, any Basic entered by you cannot be saved in a MS doc

TonyP gravatar imageTonyP ( 2012-03-04 19:04:17 +0100 )edit
0

answered 2012-03-02 00:59:38 +0100

This is a missing feature.

We are not yet able to save VBA macros back to xls/xlsx files. There has been an Easy HAck for some time for this but nobody had yet the courage to work on this.

Please keep in mind that xls/xlsx and VBA are not our native formats and are internally always transformed to more or less a different repesentation.

edit flag offensive delete link more

Comments

I was trying to create a macro in Libre. I believe that's called Basic vs. VBA. I want to use a Libre Basic Macro in an xls only under Libre. I have other reasons for needing the files in xls vs. ods.

From what you say, it looks like I have to wait for more work to be done on the Macro section.

sophos7 gravatar imagesophos7 ( 2012-03-02 18:18:01 +0100 )edit

Including Star Basic macros can't work at all. XLS/XLSX does not support to add this, so if you want to add Star Basic macros you are forced to use ods. If you want to use VBA you can use ods, xls and xlsx for import but only ods for export.

moggi gravatar imagemoggi ( 2012-03-02 23:55:29 +0100 )edit

Question Tools

1 follower

Stats

Asked: 2012-02-28 20:35:35 +0100

Seen: 6,062 times

Last updated: Jan 20 '13