Hi Sven,

you misunderstand some things. For example the Dim foo as new ... is
the prefered syntax for declaring foo to be of a certain struct type,
and *only* of UNO struct types.
The object as identified in the IDL with the name of
"com.sun.star.text.TextField" is a service, that can only be
constructed during runtime by asking the XMultiServiceFactory of the
document model to create it for you.
example:
<code>
Sub Main
 Dim otxtfield as Variant
 odoc = thisComponent 'currently active document
 otxtfield = odoc.createInstance("com.sun.star.text.TextField")
End Sub
</code>

Note that I declared otxtfield of type Variant, not of type Object
because there are some rare situations where it would fail declaring a
variable of type Object.
As about your question - assigning a known control object to a
variable can easily be done declaring the variable of type Variant
before, or to not declare it at all.
Others reading your code will recognize what type a variable has by
just looking at the variable name (otxtfield is very clear to me).

All of this is documented in the Developer's Guide by the way. So have a look at
http://api.openoffice.org or download the SDK which has new objects -
presented in 2.0 beta - listed and to some extent documented in its
IDL reference.


2005/8/29, Victoria, Sven <[EMAIL PROTECTED]>:
> Hi,
> 
> I would like to declare a control variable (reference) in StarBasic and 
> assign an existing control to it
> from an existing dialog like:
> 
> Dim textField  As com.sun.star.text.TextField
> textField = dialog.getControl("txtKlantNr")
> 
> Hoewever the error I get here is: "unknown data type 
> com.sun.star.text.TextField" and the code
> won't run. Declaring with 'as new' like:
> 
> Dim textField  As new com.sun.star.text.TextField
> 
> generates the following error:
> 
> "Object not accessible. Invalid object reference." but the code will run 
> anyway although it won't
> run as intended.
> 
> Declaring the object as Object will give me no errors but I do not want to 
> declare it
> as an Object since I know for sure it is a com.sun.star.text.TextField. This 
> way it
> will be easier for me and others to know with which interfaces we are dealing 
> with, and
> to look these up in the documentation.
> 
> Any suggestions?
> 
> Regards,
> Sven
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
Best Regards
Christian Junker

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to