OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

edit controls in a dialog

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
wasgedkongred
General User
General User


Joined: 22 Aug 2005
Posts: 12

PostPosted: Wed Aug 24, 2005 11:35 am    Post subject: edit controls in a dialog Reply with quote

hi everybody,

i've just started to program in ooo basic.
i want to change the text of a textfield or in general: edit a control on a dialog.
with the following code i can only set the text property of the new dialog that is created with this code:

Sub whatever
dim dlg, dlgBeschreibung, TextField1 as object
dlgBeschreibung = DialogLibraries.Standard.BspDlg
dlg = createUnoDialog(dlgBeschreibung)
TextField1 = dlg.getControl("TextField1")
TextField1.model.text="Test"
dlg.Execute()
End Sub

if i try it like this, i get error msges: "object variable not set"
Sub whatever
'dim dlg, dlgBeschreibung, TextField1 as object
'dlgBeschreibung = DialogLibraries.Standard.BspDlg
'dlg = createUnoDialog(dlgBeschreibung)
TextField1 = dlg.getControl("TextField1")
TextField1.model.text="Test"
dlg.Execute()
End Sub

so obviously i have to tell basic where the textfield is...on which dialog.
how do i do that?
thx in advance

wasgedkongred
Back to top
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Wed Aug 24, 2005 12:01 pm    Post subject: Reply with quote

I have some comments on your code. First, you create two variables of type Variant and one of type object. You need to explicitly provide a type for every variable. Common mistake.
Code:
dim dlg, dlgBeschreibung, TextField1 as object

Now on to the code that generates the error. I have recreated it here with comments.
Code:

Sub whatever
  REM This code is commented out so you never define any variables.
  'dim dlg, dlgBeschreibung, TextField1 as object

  REM Code is commented out so you do not load the dialog description.
  'dlgBeschreibung = DialogLibraries.Standard.BspDlg

  REM Code is commented out so you do not create the dialog.
  'dlg = createUnoDialog(dlgBeschreibung)

  REM You use the variable named dlg, which has not been defined.
  REM If you used "Option Explicit" at the top of your module then this
  REM would generate a variable not defined error.
  REM You did not, so it tries to use the variable named "dlg".
  REM The variable is not defined so it automatically creates a variable
  REM of type Variant. The initial value is Empty. You then try to use this
  REM empty variable, which generates an error. The error is that the
  REM variable has not been assigned anything useful, or as the error message says:
  REM "object variable not set"
  TextField1 = dlg.getControl("TextField1")
  TextField1.model.text="Test"
  dlg.Execute()
End Sub

_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group