How to Put text from dialog into a cell

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Harold
Posts: 3
Joined: Sat Apr 26, 2008 11:24 pm

How to Put text from dialog into a cell

Post by Harold »

ill probably have a few more questions like these before im done with this :/ hope you guys dont mind. im trying to change the cell named "S1_artnum" on sheet named "invullen" to whatever is entered on the dialog in textfield "S1artnum_tkst"

Code: Select all

Sub Afdrukken
	
	Dim oVoorraadstickers as Object
	Dim oInvullen_blad as Object
	Dim oS1_artnum_cel as Object
	Dim oS1artnum_tkst as Object

	oVoorraadstickers = thisComponent
	oInvullen_blad = oVoorraadstickers.Sheets.getByName ("Invullen")
	oS1artnum_tkst = oInvoer_scherm.getControl("S1artnum_tkst")
	oS1artnum_cel = oInvullen_blad.getCellRangeByName("S1_artnum")
	oS1artnum_cel.Text( ,0) = oS1artnum_tkst.Text( ,0)

End Sub
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to Put text from dialog into a cell

Post by Villeroy »

getCellRangeByName(str) returns a range rather than cell.

Code: Select all

...
sText = oS1artnum_tkst.getText() 'or getSelectedItem() for a list box

oS1artnum_cells = oInvullen_blad.getCellRangeByName("S1_artnum")

oS1artnum_cel = oS1artnum_cells.getCellByPosition(0,0)
oS1artnum_cel.setString(sText)
Install a recent copy of the SDK (includes documentation) and the XRay tool:
http://ooomacros.org/dev.php#101416
http://download.openoffice.org/2.4.0/sdk.html
so every object can tell you everything about itself.
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
Post Reply