Hi Friends,
Are they any Special Macro Code there in STAR BASIC - Calc Marco Like in VBA (MS-Office) ActiveWorkBook and ThisWorkBook ?
Hi Friends,
Are they any Special Macro Code there in STAR BASIC - Calc Marco Like in VBA (MS-Office) ActiveWorkBook and ThisWorkBook ?
If you want to actually program for LibreOffice you need to study how the API can be used. A good source for learning about it are the OpenOffice-Basic texts by Andrew Pitonyak independent of the “Basic” in the title". Indispensible is the usage of LibreOffice: com::sun::star Module Reference and older related sites (from OOo times).
Basic or any different programming language each need a bridge to that API, and Basic comes with a rather comfortable one though it otherwise is a comparably poor language.
VBA ( for Word / for Excel / for someting) may be richer in tools, but mainly they seem to be at the same time the API to the respective Applications. This is very different as compared to the concept of LibreOffice.
I would assume that you won’t be able to write good and useful code for LibO if you insist on “thinking VBA”.
LibO Basic comes with limited support for VBA, but this is mainly intended to run VBA code included with “alien” documents in simple cases, not for active programming.
If the code is embedded, ThisComponent always refers to the embedding document, otherwise it refers to the document in the currently active window not counting the Basic IDE but counting Writer, Impress, Base etc. This is one application for all types of documents.
StarDesktop.getCurrentComponent() always refers to the component in the currently active window including the Basic IDE.
hallo
#basic:
doc = thisComponent
#python:
doc = XSCRIPTCONTEXT.getDocument()
Hi Karolus,
I want like this in LO BASIC Calc Macros - To Differentiate STAR BASIC Code is Stored in Calc Document and ActiveCalcDocument like this below
In VBA
ActiveWorkbook vs. ThisWorkbook
It’s important to the know the difference between the ActiveWorkbook and ThisWorkbook in
The ActiveWorkbook is the workbook that is currently active (similar to how [ActiveSheet] is the currently active sheet).
ThisWorkbook is the workbook where the VBA code is stored. ThisWorkbook will never change.
ActiveWorkbook represents the Workbook in active window which has focus on the screen.
ThisWorkbook represents the current Workbook in which the current VBA code is running or executing.
Both commands above points to »thisWorkbook« if the code is stored in the Document, otherwise to the actually active Component.
Hi JohnSUN,
I have read this page … But, I have doubt that. So, I am asking Like VBA - ThisWorkBook vs ActiveWorkBook.
For Example : Doc1 have - Macro that Copy and Paste Between - Two Different Calc Docments ( Doc2 as Source Data- Copy and Doc3 as Destination Data - Paste ) which are in " D:\ " drive in Windows 11 Os.
and Doc1 have ( which is having Macro ) in " E:\ " Drive
LibreOffice has some level of VBA compatibility (with the respective option). It supports both ThisWorkBook
and ActiveWorkBook
. They are intended to work as in Excel (if they don’t, it would be a bug).
However, this is a VBA-only concept. You are asking how to get the LibreOffice Basic equivalent for ThisWorkBook
(and there is none), instead of asking how to solve a problem that you imagine to need ThisWorkBook
to.
Show the macro. Why would it need to know where the macro itself is stored?
Hi Mikekaganski,
So, Which Situation should i use – StartDesktop.CurrentComponent –