[VB6]Questions et problèmes sur OpenOffice
Bonjour à tous,
Voilà, j'ai quelques petites questions sur Open Office :
1) Voici un exemple de code (qui fonctionne bien). Le problème, c'est que j'ai remarqué que les process "sOffice.exe" et "sOffice.bin" ne se ferment pas après l'éxécution de ce code qui me parrait tout à fait correct (avec fermeture des objets ouverts, ...).
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
'Vérifie la présence d'OpenOffice Calc sur le poste utilisateur
Public Function CheckIfOOoCalcInstalled() As Boolean
Dim oServiceManager As Object
Dim oDesktop As Object
Dim oDocument As Object
Dim oOpenParam(2) As Object 'a Visual Basic array, with 3 elements
Dim ErrMsg As String
On Error GoTo ErrHandler
'Création d'un service OpenOffice.org
Set oServiceManager = CreateObject("com.sun.star.ServiceManager")
Set oDesktop = oServiceManager.CreateInstance("com.sun.star.frame.Desktop")
'We call the MakePropertyValue function, defined just before, to access the structure
Set oOpenParam(0) = MakePropertyValue("ReadOnly", True)
Set oOpenParam(1) = MakePropertyValue("Password", "")
Set oOpenParam(2) = MakePropertyValue("Hidden", True)
'Création d'un nouveau classeur
Set oDocument = oDesktop.loadComponentFromURL("private:factory/scalc", "_blank", 0, oOpenParam())
Call oDocument.Close(False) 'emeture sans sauvegarde
' Suppression des objets pour libérer la mémoire
Set oDocument = Nothing
Set oDesktop = Nothing
Set oServiceManager = Nothing
CheckIfOOoCalcInstalled = True
Exit Function
ErrHandler:
CheckIfOOoCalcInstalled = False
Exit Function
End Function
'Creates a sequence of com.sun.star.beans.PropertyValue s
Public Function MakePropertyValue(cName, uValue) As Object
Dim oStruct, oServiceManager As Object
Set oServiceManager = CreateObject("com.sun.star.ServiceManager")
Set oStruct = oServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
oStruct.name = cName
oStruct.Value = uValue
Set MakePropertyValue = oStruct
End Function |
Que manque-t-il pour tuer correctement les process ?
2) Dans la fonction MakePropertyValue faut-il fermer l'objet oServiceManager ? J'ai trouvé cette fonction telle qu'elle sur le site officielle de OOo, donc ...
3) Quelle commande utiliser pour faire un retour chariot dans le writer (Word).
Merci d'avance pour votre aide.
++