I left this question behind for quite a while, but now I experimented a bit
more with it and I came up with the following macro example, which works
for a dialogue called ”ElDialog” including a date field called ”DateField”
that has to be created before running the macro:
Sub test
Dim oDlg As com.sun.star.awt.XUnoControlDialog
Dim oCtl As com.sun.star.awt.XDateField
DialogLibraries.LoadLibrary("Standard")
oDlg=CreateUnoDialog(DialogLibraries.Standard.ElDialog)
oCtl=oDlg.getControl("DateField")
Dim oDate As com.sun.star.util.Date
oDate=createUnoStruct("com.sun.star.util.Date")
oDate.Year=2018
oDate.Month=9
oDate.Day=2
oCtl.setDate(oDate)
oDlg.execute
End Sub
So the dialogue can obviously be declared as
com.sun.star.awt.XUnoControlDialog.
When it comes to controls, i tdepends on what type of control. For a date
field, com.sun.star.awt.XDateField seems to be it.
For this to work, the enhanced IDE features must be enabled.
I can also declare a date as com.sun.star.util.Date, rather than just Object.
When doing that, I get suggestions as I type. In the case above, when I
type ”oDate.”, I get Day, Month and Year as suggestions. That makes the
whole thing a little bit easier, I think. Maybe the macro also runs a
little faster, I don't know.
Den mån 20 nov. 2017 kl 16:41 skrev Johnny Rosenberg <[email protected]
>:
> 2017-11-20 0:40 GMT+01:00 Andrew Pitonyak <[email protected]>:
>
>> Sorry, using my phone for this... And off the top of my head...
>>
>> Each object usually supports multiple interfaces...
>>
>> In basic, the actual type does not matter.
>>
>> Names starting with an x refer to an interface.
>>
>> I need to look it up, but I think that the preference was a variant
>> rather than object, but...
>>
>> It may no longer matter
>>
>> The developer who told me this could not remember why it when it mattered
>>
>> And
>>
>> I only had a problem because of it once, and that was years ago.
>>
>> Other languages, like Java, it matters. I'd we had a smarter IDE it might
>> be useful to declare the actual type.
>>
>>
> According to the little information I found, types like Variant and Object
> are considered slow. Probably fast enough for most situations, but fast is
> never a bad thing, is it?
> Also, I'm trying out the other new "experimental" features as well, such
> as… whatever that's called in English… code expansion? Text expansion? That
> is, when I type I get suggestions. This only work with the new extended
> data types.
>
> I work with VBA in Excel at work (that's what they have so that's what I
> must use), and I kind of miss that feature. In LibreOffice, it means that I
> don't have to use xray as much as otherwise. Another minor thing I miss
> from Excel VBA, is that I can see the value of a variable by just hovering
> the mouse pointer over it. Excel has a lot of nasty bugs though, I don't
> miss them… :P Not said that LibreOffice Calc is bugfree in any way, there
> are some, there too.
>
> Anyway, at the moment I'm only experimenting with it, just for fun, but it
> would be nice to see some documentation of all this. If examples are
> included – even better.
>
>
> Kind regards
>
> Johnny Rosenberg
>
>
>
>>
>> Sent from BlueMail <http://www.bluemail.me/r?b=11061>
>> On Nov 19, 2017, at 5:31 PM, Johnny Rosenberg <[email protected]>
>> wrote:
>>>
>>> Oops, sorry. I did it again, I accidentally replied privately rather than
>>> to the list. I'm sorry for that, Robert.
>>>
>>> ---------- Forwarded message ----------
>>> From: Johnny Rosenberg <[email protected]>
>>> Date: 2017-11-19 23:19 GMT+01:00
>>> Subject: Re: [libreoffice-users] Macro Dim Dialog and Control
>>> To: Robert Großkopf <[email protected]>
>>>
>>>
>>> 2017-11-19 20:00 GMT+01:00 Robert Großkopf <[email protected]>:
>>>
>>> Hi Jonny,
>>>>
>>>>>
>>>>> This works, but what about oDlg and oCtl? Are there special data types
>>>>>
>>>> for
>>>>
>>>>> them too? The documentation I've found so far doesn't give any hints at
>>>>> all. I tried this:
>>>>> Dim Dlg As com.sun.star.awt.XDialog ' No error here,
>>>>> ' but next line throws an error:
>>>>> oDlg = CreateUnoDialog(DialogLibraries.Standard.MyDialogue)
>>>>> ' Error: No access to object.
>>>>> ' Invalid usage of the object.
>>>>> ' Well, something like that, it's actually in Swedish.
>>>>>
>>>>
>>>> What is the name of the dialog? Is ist called "MyDialogue"?.
>>>>
>>>
>>>
>>> No, I actually faked it for this mailing list. The real name is in Swedish,
>>> so I figured it would be easier for you guys if I picked an English name
>>> instead, just for this example. But the name isn't the problem anyway. My
>>> question is if there is an ”extended data type” for dialogs and controls,
>>> just like there is for sheets (com.sun.star.sheet.XSpreadsheet) and cells (
>>> com.sun.star.table.XCell). I searched for and while and thought that
>>> com.sun.star.awt.XDialog could be it for dialogs, but as I said, I got that
>>> error message. When I used Object, like you do below, everything worked for
>>> me too, but my question wasn't about getting it working, it was if there is
>>> such a data type. I'm not doing anything particular, I'm just trying to
>>> learn this new stuff about those ”new data types”, that I enable by
>>> selecting Tools → Options… → LibreOffice → Advanced → Activate experimental
>>> features, then restart LibreOffice, then Tools → Options… → LibreOffice →
>>> Basic IDE options → ☒ Use extended data types (give or take some words or
>>> phrases, since this is a translation from Swedish).
>>>
>>> When trying to get information I found this page:
>>> https://help.libreoffice.org/Common/Basic_IDE_Options#Use_extended_types
>>>
>>> However, they only provided two examples of those new data types (the two I
>>> mention above), and there's no link or anything that points to the rest of
>>> them, so it's pretty useless, unfortunately.
>>>
>>>
>>> It should
>>>> appear at the left (catalog of objects - don't konwo if this is the
>>>> right name ..) and at the bottom (like the standard "Module1")
>>>>
>>>> Declare the dialog first, out of a sub:
>>>> DIM oDialog0 AS OBJECT
>>>>
>>>> Start the dialog:
>>>>
>>>> SUB Dialog0Start
>>>> DialogLibraries.LoadLibrary("Standard")
>>>> oDialog0 = createUnoDialog(DialogLibraries.Standard.Dialog0)
>>>> oDialog0.Execute()
>>>> END SUB
>>>>
>>>> Name of the dialog is "Dialog0"
>>>>
>>>> End the dialog:
>>>>
>>>> SUB Dialog0Ende
>>>> oDialog0.EndExecute()
>>>> END SUB
>>>
>>>
>>>
>>> Yes, that's how I used to do it, and it usually work for me too, but this
>>> wasn't what I asked about. My question is about those new data types,
>>> mentioned on the page I referred to above.
>>>
>>> I'm sorry for my confusing English, which obviously isn't my native
>>> language.
>>> Thanks for replying, though! :)
>>>
>>>
>>> Kind regards
>>>
>>> Johnny Rosenberg
>>>
>>>
>>>
>>> Regards
>>>>
>>>> Robert
>>>> --
>>>> Homepage: http://robert.familiegrosskopf.de
>>>> LibreOffice Community: http://robert.familiegrosskopf.de/map_3
>>>>
>>>>
>>>> --
>>>> To unsubscribe e-mail to: [email protected]
>>>> Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-un
>>>> subscribe/
>>>> Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
>>>> List archive: https://listarchives.libreoffice.org/global/users/
>>>> All messages sent to this list will be publicly archived and cannot be
>>>> deleted
>>>
>>>
>>>
>
--
To unsubscribe e-mail to: [email protected]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy