Voici un code qui fonctionne. Vois comment est rédigé Sub Copy().
Cordialement.
Je te fais passer mes "trouvailles".
Dim oServiceManager As Object, oDispatcher As Object
Dim oDesktop As Object, oDocument As Object, oSel As Object
Sub openDoc(ByVal FichierATraiter As String, Optional ByVal
clInvisible As Boolean = False)
Dim Arguments(0) As Object
Dim FichierFormaté As String
LoadService()
Arguments(0) = MakePropertyValue("Hidden", clInvisible)
FichierFormaté = ConvertToUrl(FichierATraiter)
oDocument = oDesktop.loadComponentFromURL(FichierFormaté,
"_blank", 0, Arguments)
SelectAll()
Copy()
CloseDoc()
End Sub
Public Function ConvertToUrl(ByVal strFile As String) As String
strFile = Replace(strFile, "\", "/")
strFile = Replace(strFile, ":", "|")
strFile = Replace(strFile, " ", "%20")
strFile = "file:///" + strFile
ConvertToUrl = strFile
End Function
Public Function MakePropertyValue(ByVal cName As String, ByVal
uValue As VariantType) As Object
Dim oStruct As Object
oStruct =
oServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
oStruct.Name = cName
oStruct.Value = uValue
MakePropertyValue = oStruct
End Function
Public Function LoadService() As Boolean
On Error GoTo Sortie
oServiceManager = CreateObject("com.sun.star.ServiceManager")
oDesktop =
oServiceManager.createInstance("com.sun.star.frame.Desktop")
oDispatcher =
oServiceManager.createInstance("com.sun.star.frame.DispatchHelper")
LoadService = True
Sortie:
LoadService = False
End Function
Public Sub Copy()
Dim Arguments(0) As Object
oSel = oDocument.CurrentController.Frame
Arguments(0) = MakePropertyValue("Hidden", False)
oDispatcher.executeDispatch(oSel, ".uno:Copy", "", 0, Arguments)
End Sub
Public Sub SelectAll()
Dim Arguments(0) As Object
Arguments(0) = MakePropertyValue("Hidden", False)
oSel = oDocument.CurrentController.Frame
oDispatcher.executeDispatch(oSel, ".uno:SelectAll", "", 0,
Arguments)
End Sub
Public Sub CloseDoc()
oDocument.Close(True)
End Sub
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]