New Collection and Dictionary like VBA
New Collection and Dictionary like VBA
In VBA is very simple to have owner generic container as Collection ( New Collection in VBA ) or Dictionary ( new Dictionary from link MSScript in scrrun.dll ), or manipolate Xml DomDocument with MsXml.dll.
And in Openoffice ???. This is very important for advanced programming.
Thank you
And in Openoffice ???. This is very important for advanced programming.
Thank you
Re: New Collection and Dictionary like VBA
Use a better programming language such as Java or Python. You get even more than VB has to offer.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: New Collection and Dictionary like VBA
It's a good idea.
I am an amateur and Unfortunately I am too old for improve others languages .
It's so difficult to improve OpenOffice Basic with linking to external library ????
thank you
I am an amateur and Unfortunately I am too old for improve others languages .
It's so difficult to improve OpenOffice Basic with linking to external library ????
thank you
Re: New Collection and Dictionary like VBA
A very valuable member of the community did some creative experiments with Python containers, callable from Basic. I could not get it working, though: http://www.oooforum.org/forum/viewtopic ... =container
I learned Python during a rainy weekend, enough to write simple backup scripts and office macros. If you've got the concept of object orientation, it is by far more easy than stupid old Basic (and you can use decent editors). No more Empty,Null,Nothing,IsMissing,Dim,Redim,DimArray,sub/function and other nonsense.
One day study: http://www.swaroopch.com/byteofpython/
Another day with other people's examples:
http://wiki.services.openoffice.org/wik ... ent_python
http://wiki.services.openoffice.org/wik ... o_language
http://wiki.services.openoffice.org/wiki/PyUNO_bridge
I learned Python during a rainy weekend, enough to write simple backup scripts and office macros. If you've got the concept of object orientation, it is by far more easy than stupid old Basic (and you can use decent editors). No more Empty,Null,Nothing,IsMissing,Dim,Redim,DimArray,sub/function and other nonsense.
One day study: http://www.swaroopch.com/byteofpython/
Another day with other people's examples:
http://wiki.services.openoffice.org/wik ... ent_python
http://wiki.services.openoffice.org/wik ... o_language
http://wiki.services.openoffice.org/wiki/PyUNO_bridge
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: New Collection and Dictionary like VBA
i have seen for python...., is very interesting....
But, why do not use
Set automationFactory = createUnoService("com.sun.star.bridge.oleautomation.Factory")
Dim objApp As Object
Set objApp = automationFactory.createInstance("Scripting.Dictionary")
It seems good !!! (Its true, needs to use MSWindows, in this case why not ???)
Are there another like this ???
thank you for your answers
But, why do not use
Set automationFactory = createUnoService("com.sun.star.bridge.oleautomation.Factory")
Dim objApp As Object
Set objApp = automationFactory.createInstance("Scripting.Dictionary")
It seems good !!! (Its true, needs to use MSWindows, in this case why not ???)
Are there another like this ???
thank you for your answers
Re: New Collection and Dictionary like VBA
I can't tell. No windows, no com.sun.star.bridge.oleautomation.Factory.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: New Collection and Dictionary like VBA
I tried just now on WindowsXP + OOo3(Basic).
If "VBASupport" to enable, "Collection" objects can be used.
Example:
If "VBASupport" to enable, "Collection" objects can be used.
Example:
Code: Select all
Option VBASupport 1
Sub Main
Dim test As Collection
Set test = New Collection
test.Add("foo", "1")
msgbox test(1)
End Sub
OOo 2.3.X on Ms Windows XP + Ubuntu
-
- Volunteer
- Posts: 1160
- Joined: Mon Oct 08, 2007 1:26 am
- Location: France, Paris area
Re: New Collection and Dictionary like VBA
This is not specific to OOo 3, you don't need VBASupport.tani wrote:I tried just now on WindowsXP + OOo3(Basic).
If "VBASupport" to enable, "Collection" objects can be used.
Here is a simpler syntax:
Code: Select all
Dim test As New Collection
test.Add("foo", "1")
msgbox test(1)
' calling an object from MS-Windows follows the same syntax
Dim fso As New Scripting.FileSystemObject
MsgBox("Number of drives : " & fso.Drives.Count)
Edit: see my next message in this thread. ______ Bernard |
Last edited by B Marcelly on Fri Feb 06, 2009 4:33 pm, edited 2 times in total.
-
- Volunteer
- Posts: 1160
- Joined: Mon Oct 08, 2007 1:26 am
- Location: France, Paris area
Re: New Collection and Dictionary like VBA
Hi,
Another thread shows more information about Collections in OOoBasic.
They are available from 2.4 and not restricted to MS-Windows.
Here is an example of a simple dictionnary. The purpose is to find the postal code of a given town.
I could not find a function to test the existence of a key. So I use error handling to detect not-existing keys.
______
Bernard
Another thread shows more information about Collections in OOoBasic.
They are available from 2.4 and not restricted to MS-Windows.
Here is an example of a simple dictionnary. The purpose is to find the postal code of a given town.
Code: Select all
Sub DictionaryExample
Dim k As String
Dim dico As New Collection
dico.Add("49000", "Angers") ' key = "Angers", Item = "49000"
dico.Add("33000", "Bordeaux")
dico.Add("09000", "Foix")
dico.Add("11350", "Cucugnan")
MsgBox("Number of elements : " & dico.Count)
Do
k = InputBox("Town : ", "Find postal code", "")
if Len(k) = 0 then Exit Do
On Error GoTo inconnu
MsgBox("Postal code : " & dico(k) ) ' the key is not case sensitive
suite1:
On Error GoTo 0
Loop
Exit Sub
inconnu:
MsgBox("Town " & k & " is unknown", 16)
Resume Suite1
End Sub
______
Bernard