[Solved] Accessing Push Button from Another Push Button

Creating a macro - Writing a Script - Using the API

[Solved] Accessing Push Button from Another Push Button

Postby ouchd'greyt » Fri Aug 04, 2017 4:17 am

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   Expand viewCollapse view
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   Expand viewCollapse view
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
ouchd'greyt
 
Posts: 28
Joined: Wed Jun 28, 2017 4:41 am

Re: Macro Accessing Other Push Button from Another Push Butt

Postby FJCC » Fri Aug 04, 2017 5:55 am

This macro changes the label of Push Button 1 on Sheet1. It can be triggered by a button on another sheet.
Code: Select all   Expand viewCollapse view
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"
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 6027
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Macro Accessing Other Push Button from Another Push Butt

Postby ouchd'greyt » Fri Aug 04, 2017 12:24 pm

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
ouchd'greyt
 
Posts: 28
Joined: Wed Jun 28, 2017 4:41 am

Re: Macro Accessing Other Push Button from Another Push Butt

Postby Zizi64 » Fri Aug 04, 2017 1:47 pm

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; LO4.4.7, LO5.3.6 on Win7x64Prof.
And the portable versions: LO3.3.0-LO5.4.1 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5893
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary


Return to Macros and UNO API

Who is online

Users browsing this forum: Google [Bot] and 8 guests