目次
索引 🔎︎

# CreateUnoValue Function

Uno タイプを明示的に指定された値を示すオブジェクトを返します。

このオブジェクトは Uno に渡す際に、自動的に該当する Any タイプに変換されます。これらのタイプ指定は、完全な Uno タイプ名を指定する必要があります。

LibreOffice API では Any タイプがよく使われます。これは、他の環境で使われる Variant タイプと対をなすものです。Any タイプは一般の Uno インタフェースで利用されているもので、任意の Uno タイプを 1 つ格納できます。

### Syntax:

oUnoValue = CreateUnoValue( "[]byte", MyBasicValue ) ' to get a byte sequence.

If CreateUnoValue cannot be converted to the specified Uno type, and error occurs. For the conversion, the com.sun.star.script.Converter service is used.

This function is intended for use in situations where the default Basic to Uno type converting mechanism is insufficient. This can happen when you try to access generic Any based interfaces, such as XPropertySet::setPropertyValue( Name, Value ) or X???Container::insertBy???( ???, Value ), from LibreOffice Basic. The Basic runtime does not recognize these types as they are only defined in the corresponding service.

In this type of situation, LibreOffice Basic chooses the best matching type for the Basic type that you want to convert. However, if the wrong type is selected, an error occurs. You use the CreateUnoValue() function to create a value for the unknown Uno type.

You can also use this function to pass non-Any values, but this is not recommend. If Basic already knows the target type, using the CreateUnoValue() function will only lead to additional converting operations that slow down the Basic execution.