I have a spreadsheet document "Experiment1" which contains a worksheet called "Test Sheet", which contains a Dialog box called "Dialog1" (which resides in a "Standard" Library inside ""My Dialogs"), which includes a Text Field called "Textfield1".
I want to be able to enter a name into the text field and then put it into a specified cell, say B25.
I can activate the dialog box and I have a macro in Module 1 in the library called "TextField1Activated" which contains the lines given below.
I have set the macro to be run on the Event "When losing focus", which allows me to enter text into the text field box.
However, nothing happens when I press enter, and when I move the focus away from this text field I get an "Object variable not set" error message at the green line in the listing below. Obviously this line is wrong, but I cannot find any guidance or examples anywhere to show me what is should read.
Code: Select all
' get cell B25
dim sheet as object
dim cell as object
dim doc as object
doc=thiscomponent
sheet=doc.sheets.getbyname("Test Sheet")
cell=sheet.getcellbyposition(1,24) ' this is cell B25 I think
dim textfieldOnedialog as object
dim textfieldOne as object
textfieldOnedialog=CreateUnoDialog(DialogLibraries.Standard.getByName("Dialog1"))
textfieldOne=textfieldOnedialog.getcontrol("Textfield1")
[color=#008040]
cell.value = textfieldOne.text[/color] ' this is a guess on my part
Any help would be most welcome.
Thank you in advance
Andrew