Jump to content

Problem opening a .xls file hidden with OpenOffice COM


 Share

Recommended Posts

Here is my code:

Func LoadDataViaOpenOffice($infilspc)
Global $errormodul ="LoadDataViaOpenOffice"
Local $osm = ObjCreate("com.sun.star.ServiceManager")
global $myOOerror = ObjEvent("AutoIt.Error","cOOErrFunc")
Local $oDesktop = $osm.createInstance("com.sun.star.frame.Desktop")

$infilspc = StringReplace($infilspc, ":", "|")
$infilspc = StringReplace($infilspc, " ", "%20")
$infilspc = "file:///" & StringReplace($infilspc, "\", "/")

;Ref: http://www.openoffice.org/api/docs/common/ref/com/sun/star/beans/PropertyValue.html
Local $OpenPar[2]
Local $oPropertyValue = $osm.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
$oPropertyValue.Name = "ReadOnly"
$oPropertyValue.Value = True
$OpenPar[0] = $oPropertyValue
Local $oPropertyValue = $osm.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
$oPropertyValue.name = "Hidden"
$oPropertyValue.value = True
$OpenPar[1] = $oPropertyValue
#cs
Local OpenPar[3]
$OpenPar[0] = cOOSetProp($osm,"ReadOnly", -1)
$OpenPar[1] = cOOsetProp($osm,"Password", "") ;setzt das passwort des dokuments
$OpenPar[2] = cOOsetProp($osm,"Hidden", -1)
#ce
MsgBox(0,"",$infilspc)
Local $oFile = $oDesktop.loadComponentFromURL( $infilspc, "_blank", 0, $OpenPar)
if @error or Not IsObj($oFile) then
MsgBox(0,"Error","$oFile")
Exit
EndIf
EndFunc
#cs
Func cOOSetProp($osm,$cName, $uValue) ;Deliver characteristics in struct
$errormodul = "_OOSetProp"
$oPropertyValue = $osm.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
$oPropertyValue.Name = $cName
$oPropertyValue.Value = $uValue
$setOOoProp = $oPropertyValue
Return $setOOoProp
EndFunc ;==>_OOSetProp
#ce

Func cOOErrFunc()
Local $nHex = Hex($myOOerror.number,8)
MsgBox(0,"COM error OpenOffice script ","Number: "&$nHex&@CRLF&"Desscription: "&$myOOerror.windescription&@CRLF&"Module: "&$errormodul)
Exit
EndFunc

As you can see, I borrowed code from the forum. Thanks, guys!

ReadOnly works OK, but spreadsheet is visible when it should be hidden.

As you can see, I tried some variations of the code

Any suggestions?

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...