[Solved] What modules are in ThisComponent

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
no_such_UNO
Posts: 15
Joined: Sat Jun 24, 2023 2:42 pm

[Solved] What modules are in ThisComponent

Post by no_such_UNO »

Sub P
Dim PPP As Object
ppp = ThisComponent.beans.getPropertyByName()
Print ppp
End Sub

Print is command that prints a string. I need to extract from ThisComponent all available values but I have no idea how. Though I need a service of getPropertyValue() but before that I have to know what module I am in. The code above errors with "Property or method not found :beans." How to see into ThisComponent?

I rewrite the code
Sub P
Dim oPPP As Object
Dim sPPP As String
oPPP = ThisComponent
sPPP = oPPP.getPropertyByName()
Print " " & sPPP
End Sub

The code errors with "Property or method not found :getPropertyByName()"
Last edited by no_such_UNO on Sat Jun 24, 2023 5:26 pm, edited 1 time in total.
LibreOffice 7.2.7.3 on LinuxMint 21.1
JeJe
Volunteer
Posts: 2785
Joined: Wed Mar 09, 2016 2:40 pm

Re: What modules are in ThisComponent

Post by JeJe »

Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
no_such_UNO
Posts: 15
Joined: Sat Jun 24, 2023 2:42 pm

Re: What modules are in ThisComponent

Post by no_such_UNO »

Thank you JeJe for your prompt reply but the beast is written in Python. I do need to learn Python then and I would appreciate something written in Basic as I am new to it and it is more natural to the office suit, at least it is my opinion.
LibreOffice 7.2.7.3 on LinuxMint 21.1
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: What modules are in ThisComponent

Post by Villeroy »

The language does not matter at all. MRI can even generate Basic code (or Java or C++ or Python).
[Tutorial] Introduction into object inspection with MRI
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
MrProgrammer
Moderator
Posts: 4909
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: [Solved] What modules are in ThisComponent

Post by MrProgrammer »

no_such_UNO wrote: Sat Jun 24, 2023 4:29 pm What modules are in ThisComponent
OpenOffice Help wrote:ThisComponent [Runtime]
Addresses the active component so that its properties can be read and set. ThisComponent is used from document Basic, where it represents the document the Basic belongs to. The type of object accessed by ThisComponent depends on the document type.

no_such_UNO wrote: Sat Jun 24, 2023 4:29 pm I need to extract from ThisComponent all available values but I have no idea how.
I would appreciate something written in Basic.
Tools → Macros → Organize Macros → OpenOffice Basic
202306250900.gif
202306250900.gif (71.41 KiB) Viewed 2110 times

WritedbgInfo(ThisComponent)
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
no_such_UNO
Posts: 15
Joined: Sat Jun 24, 2023 2:42 pm

Re: [Solved] What modules are in ThisComponent

Post by no_such_UNO »

MrProgrammer it s tough! But how to use these macros? No relevant manual I can find. And yet this is buggy

Sub SetBasicReadOnlyFlag(bReadOnly as Boolean)
Dim i as Integer
Dim LibName as String
Dim BasicLibNames() as String
	BasicLibNames() = BasicLibraries.ElementNames()
	For i = 0 To Ubound(BasicLibNames())
		LibName = BasicLibNames(i)
		If LibName <> "Standard" Then
			BasicLibraries.SetLibraryReadOnly(LibName, bReadOnly) <<arguments is not optional
		End If
	Next i
End Sub

But my wish is fulfilled. Thank you.

 Edit: But how to use these macros? is a new subject and would need a new topic. The current topic concerns ThisComponent. 
-- MrProgrammer, forum moderator  
Last edited by MrProgrammer on Thu Jun 29, 2023 4:05 pm, edited 2 times in total.
Reason: Add fomatting tags
LibreOffice 7.2.7.3 on LinuxMint 21.1
Post Reply