[Solved] Accessing Push Button from Another Push Button

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
ouchd'greyt
Posts: 28
Joined: Wed Jun 28, 2017 4:41 am

[Solved] Accessing Push Button from Another Push Button

Post by ouchd'greyt »

Hi community,

I have a problem in my macro, i don't get it how to access or to get the properties of a command button to another command button in Calc this.
Yes in Dialog i can get properties the other command button but in Calc, it make me :crazy: .

I want to access the other command button because i want to change the label on it using other button.

Case:
I have one PUSH BUTTON in Sheet1 and one PUSH BUTTON in Sheet2 now in Macro using PUSH BUTTON in Sheet2 i want to access the PUSH BUTTON in Sheet1 so just i can change the Label on it.

Code in PUSH BUTTON in Sheet1

Code: Select all

Sub Datas(Event as Object)
Dim Form As Object
'Dim sMessage
'Dim sProceed
'Dim sDialogType

  	
  	Form		= Event.Source.Model.Parent
  	btn_item1	= Form.getByName("btn_request")

End Sub 

Code in PUSH BUTTON in Sheet2

Code: Select all

Sub delete_item1

	sheet1 = ThisComponent.Sheets.getByName("Sheet1")
	borrowerform	= ThisComponent.Sheets.getByName("borrower's form")	
	
	'btn_item = Form.getByName("btn_request") '
	
End Sub	
Last edited by Hagar Delest on Sun Aug 06, 2017 9:50 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 4.1.2 on Windows 7
FJCC
Moderator
Posts: 9277
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Macro Accessing Other Push Button from Another Push Butt

Post by FJCC »

This macro changes the label of Push Button 1 on Sheet1. It can be triggered by a button on another sheet.

Code: Select all

oSheets = ThisComponent.Sheets
oSheet1 = oSheets.getByName("Sheet1")
oDrawPage = oSheet1.getDrawPage()
oForms = oDrawPage.getForms()
oForm = oForms.getByName("Form")
oButton = oForm.getByName("Push Button 1")
oButton.Label = "New Label"
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
ouchd'greyt
Posts: 28
Joined: Wed Jun 28, 2017 4:41 am

Re: Macro Accessing Other Push Button from Another Push Butt

Post by ouchd'greyt »

Hi FJCC,

Thank you so much for reading my post and answering it, so much appreciated on it :D
by the way what that's DrawPage for?..just curious so i can understand it..

Thanks a lot..
OpenOffice 4.1.2 on Windows 7
User avatar
Zizi64
Volunteer
Posts: 11360
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Macro Accessing Other Push Button from Another Push Butt

Post by Zizi64 »

by the way what that's DrawPage for?
The DrawPage is a LAYER on the Sheet above the cells (a layer, as like in the Draw application). Imagine it as a transparent graphical sheet.

The Writer, the Calc, and the Draw applications has such layer for the graphical elements. When you place a graphical object "onto" a Calc sheet, that will not located inside a cell or inside some cells, but it will located ABOVE the cells: on the graphical layer.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Post Reply