Import & export Basic libraries ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Import & export Basic libraries ?

CHRISTOPHE JOYAU
Hello,

I'm looking for a way to import Basic Libraries with Open Office 4.X about Libraries of a component (not about Globalscope Libraries).

I know to export with :

Librairies=BasicLibrairies
For Each Librairie In Librairies()
BasicLibraries.exportLibrary(Librairie.Name,ConvertToUrl(Chem & "Basic"),com.sun.star.ucb.AuthenticationRequest)
Next

So i get in directory Chem & "Basic" => xba and xlb


I 'd like to do inverse operation and it 's not working if i use
BasicLibraries.CreateLibraryLink(R,ConvertToUrl(Chem & "Basic\" & R),False)

With this command i can obtain a new library R in my component but with an error and it's empty and with a password " " ( it's mad !) .

Could you please endicate the good command to import libraries ?

Thank you for your attention and i hope your answer !
Avec mes salutations,
Christophe Joyau
Pupitreur assistant-Utilisateurs
C entre I nterrégional de S aisie des D onnées
22 bis avenue du 8 mai 1945
95200 Sarcelles
Tel : 09.70.27.18.57
' Ensemble des librairies contenues dans Clas ( il aurait été plus simple d'utiliser seulement )

SOS
Reply | Threaded
Open this post in threaded view
|

Re: Import & export Basic libraries ?

SOS
Chrstophe,

maybe this 2 BASIC subs clould help

sub AddBasicLibrary(srcname,destname)
Dim oSrcDoc as object
Dim SrcLibraryName As String, DestLibraryName As String
Dim oSrcLib As Object, oDestLib As Object, iCounter As Integer
Dim oSrc2Lib As Object , oDest2Lib As Object
Dim iLib As Integer
Dim ModuleName AS String, oModule AS Object
Dim sSrcModules
' set these 2 variables to your lib name
SrcLibraryName = srcname' library that contains the modules
DestLibraryName = destname
' This library will be created and is the
' destination for the modules from the source document.
Dim mFileProperties(0) As New com.sun.star.beans.PropertyValue


    mFileProperties(0).Name="Hidden"
    mFileProperties(0).Value= true
   ' on local error goto geenfile
    oSrcDoc =
StarDesktop.LoadComponentFromURL(ConvertToURL("t:\template\artikels\macros\Macros_Opmaak_artikels_LaatsteVersie.odt"),
"_blank", 0, mFileProperties())

oSrcLibs = oSrcDoc.BasicLibraries
oDestLibs = BasicLibraries 'out of this document
oSrcLibs.LoadLibrary(SrcLibraryName)    '[DL] Added LoadLibrary
For iLib = 1 To 2 ' this makes two passes, one for the dialogues and one
for the macros
     If oDestLibs.hasByName( DestLibraryName ) = TRue Then
        DeleteBasicLibrary( DestLibraryName) ' = SUB om leeg te maken
        oDestLibs.createLibrary(DestLibraryName )
     else
        oDestLibs.createLibrary(DestLibraryName )
     End If
     If oSrcLibs.hasByName( SrcLibraryName ) Then
         oSrcLib = oSrcLibs.getByName( SrcLibraryName )
         oDestLib = oDestLibs.getByName(DestLibraryName)
         sSrcModules = oSrcLib.getElementNames()
         iCounter = lBound( sSrcModules() )
         while( iCounter <= uBound( sSrcModules() ) )
             If oDestLib.hasByName( sSrcModules(iCounter) ) = False Then
'                On Error Goto ErrorHandler
                 oDestLib.insertByName(  sSrcModules(iCounter),
oSrcLib.getByName( sSrcModules(iCounter) )
             End If
             iCounter = iCounter + 1
         wend
     End If
     oSrcLibs = oSrcDoc.DialogLibraries  'DialogLibraries ' The same for
the Dialog libraries
     oDestLibs = DialogLibraries
     oSrcLibs.LoadLibrary( SrcLibraryName )    '[DL] Added LoadLibrary
Next iLib
'end if
oSrcDoc.dispose

Exit sub

Geenfile:
'    Style = 48 'OKonly + Exclamation
     MsgBox "ERROR bij het laden van
t:\template\artikels\macros\Macros_Opmaak_artikels_LaatsteVersie.odt" &
chr(13) & "Bestaat niet !!!"
'    AddBasicLibrary = False
End Sub

Sub DeleteBasicLibrary( srcname)
Dim DelLibraryName As String
Dim oDelLib As Object, iCounter As Integer
Dim oLib As Object, oGlobalLib As Object
Dim iLib As Integer
Dim sSrcModules
DelLibraryName = srcname
     oLib =  BasicLibraries ' For Basic libaries in this document
For iLib = 1 To 2 ' this makes two passes, one for the dialogues and one
for the macros
     If oLib.hasByName( DelLibraryName ) Then
         oLib.removeLibrary( DelLibraryName )
     End If
     oLib = DialogLibraries
Next iLib

End Sub


On 05/10/2017 11:00, CHRISTOPHE JOYAU wrote:

> Hello,
>
> I'm looking for a way to import Basic Libraries with Open Office 4.X about Libraries of a component (not about Globalscope Libraries).
>
> I know to export with :
>
> Librairies=BasicLibrairies
> For Each Librairie In Librairies()
> BasicLibraries.exportLibrary(Librairie.Name,ConvertToUrl(Chem & "Basic"),com.sun.star.ucb.AuthenticationRequest)
> Next
>
> So i get in directory Chem & "Basic" => xba and xlb
>
>
> I 'd like to do inverse operation and it 's not working if i use
> BasicLibraries.CreateLibraryLink(R,ConvertToUrl(Chem & "Basic\" & R),False)
>
> With this command i can obtain a new library R in my component but with an error and it's empty and with a password " " ( it's mad !) .
>
> Could you please endicate the good command to import libraries ?
>
> Thank you for your attention and i hope your answer !
> Avec mes salutations,
> Christophe Joyau
> Pupitreur assistant-Utilisateurs
> C entre I nterrégional de S aisie des D onnées
> 22 bis avenue du 8 mai 1945
> 95200 Sarcelles
> Tel : 09.70.27.18.57
> ' Ensemble des librairies contenues dans Clas ( il aurait été plus simple d'utiliser seulement )
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Import & export Basic libraries ?

Andrew Pitonyak
In reply to this post by CHRISTOPHE JOYAU

Sadly, I do not have time to look into this right now, but, I believe
that I may have some useful examples in one of my documents. I do not
remember which one. The documents to check (and I do not have local
copies where I am now) are either:

I would check in this order:

http://www.pitonyak.org/database/
(1) Random DB Ramblins: http://www.pitonyak.org/database/AndrewBase.odt


http://www.pitonyak.org/oo.php
(2) OpenOffice.org macros Explained:
http://www.pitonyak.org/OOME_3_0.odt
(3) English macro Document: http://www.pitonyak.org/AndrewMacro.odt


In (1), I think that I directly manipulate macros, creating and then
running them. In (2) I think that I have a section on manipulating
libraries. (3), well, I just don't remember at the moment what I have in
there related to macro libraries.



On 2017-10-05 5:00, CHRISTOPHE JOYAU wrote:

> Hello,
>
> I'm looking for a way to import Basic Libraries with Open Office 4.X
> about Libraries of a component (not about Globalscope Libraries).
>
> I know to export with :
>
> Librairies=BasicLibrairies
> For Each Librairie In Librairies()
> BasicLibraries.exportLibrary(Librairie.Name,ConvertToUrl(Chem &
> "Basic"),com.sun.star.ucb.AuthenticationRequest)
> Next
>
> So i get in directory Chem & "Basic" => xba and xlb
>
>
> I 'd like to do inverse operation and it 's not working if i use
> BasicLibraries.CreateLibraryLink(R,ConvertToUrl(Chem & "Basic\" &
> R),False)
>
> With this command i can obtain a new library R in my component but
> with an error and it's empty and with a password " " ( it's mad !) .
>
> Could you please endicate the good command to import libraries ?
>
> Thank you for your attention and i hope your answer !
> Avec mes salutations,
> Christophe Joyau
> Pupitreur assistant-Utilisateurs
> C entre I nterrégional de S aisie des D onnées
> 22 bis avenue du 8 mai 1945
> 95200 Sarcelles
> Tel : 09.70.27.18.57
> ' Ensemble des librairies contenues dans Clas ( il aurait été plus
> simple d'utiliser seulement )