Ask Your Question
0

Get/Set value from/to Cell in LibreOffice BASIC

asked 2016-05-30 03:14:05 +0200

imrdnm gravatar image

I have the following code in Microsoft Office Excel, in a .xlsm file, that's part of a VBA Sub.

'Read a value in a Cell that is named cellName
'and stores in a variable named aVariable

aVariable = Range("cellName").Value


'Read the value from a variable named aVariable
'and stores in a Cell that is named cellName

Range("cellName").Value = aVariable

How do I rewrite this so it's compatible to Libre Office Calc Basic (.ods, using LibreOfficeCalc)? Is there a way to do this that is both compatible with the Microsoft Office and Libre Office?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2016-05-30 18:14:53 +0200

peterwt gravatar image

A spreadsheet is created using MS Excel which contains VBA code. If this .xlsm file is opened in LO in most cases the VBA code will run. When the file is open in LO look at the macros contained in the file. You will find VBAProject > Modules > Module1 contains the VBA code. The code will be preceded with

Rem Attribute VBA_ModuleType=VBAModule
Option VBASupport 1

The VBAModule attempts to run the VBA code without converting to LO Basic.
If you write code in LO Basic then it will not run if you open the file with MS Excel.
So if you want to be able to open the file and run macros in both MS Excel and LO then use VBA code with the VBASupport set for compatibility..

edit flag offensive delete link more

Comments

Could you just add the libreoffice equivalent code?

imrdnm gravatar imageimrdnm ( 2016-08-03 13:56:11 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-05-30 03:14:05 +0200

Seen: 3,308 times

Last updated: May 30 '16