Mehomic Posted June 14, 2023 Share Posted June 14, 2023 I have just noticed the OP wanted details for a .docx file. I've not tried one, only an ODF file as a test. All works as it should. I have adapted my code with the details recently posted by @Heiko expandcollapse popup#include <MsgBoxConstants.au3> $fname = "full/file path/and filename/with.extension" $cURL = Convert2URL($fname) $oServiceManager = ObjCreate("com.sun.star.ServiceManager") ;< create the service manager $oDesktop = $oServiceManager.createInstance("com.sun.star.frame.Desktop") ;< create the desktop object Global $args[3] ;< set the array of properties $args[0] = MakePropertyValue("ReadOnly", False) $args[1] = MakePropertyValue("Password", "") $args[2] = MakePropertyValue("Hidden", False) $oDoc = $oDesktop.loadComponentFromURL($cURL, "_blank", 0, $args) ;< open an existing document #cs WARNING: Selecting the ViewCursor from PageStyles, the cursor must be on the page you want details returned. A single page document will always show the default settings. A document can have many pages formatted as portrait or landscape or a mixture of both. #ce $ViewCursor = $oDoc.CurrentController.getViewCursor() $PageStyle = $ViewCursor.PageStyleName $Style = $oDoc.StyleFamilies.getByName("PageStyles").getByName($PageStyle) $PageHeight = $Style.height $PageWidth = $Style.width $PageOrientation = $Style.isLandscape ConsoleWrite($PageHeight & " x " & $PageWidth &@LF) ConsoleWrite("Page is landscape: " & $PageOrientation &@LF) MsgBox($MB_SYSTEMMODAL, "RESULTS", "Is Landscape: " & $PageOrientation & @CRLF & _ "Page Width: " & $PageWidth & @CRLF & _ "Page Height: " & $PageHeight & @CRLF & _ "Page/Paper Size: " & $PageHeight/100 & "x " & $PageWidth/100) if @error or Not IsObj($oDoc) then SetError(1, 0, 0) EndIf Func MakePropertyValue($cName, $uValue) Local $Pstruc $Pstruc = $oServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue") $Pstruc.Name = $cName $Pstruc.Value = $uValue Return $Pstruc EndFunc Func Convert2URL($fname) $fname = StringReplace($fname, ":", "|") $fname = StringReplace($fname, " ", "%20") $fname = "file:///" & StringReplace($fname, "\", "/") Return $fname EndFunc code Mehomic mLipok 1 Link to comment Share on other sites More sharing options...
Solution Heiko Posted June 15, 2023 Author Solution Share Posted June 15, 2023 (edited) Here is the complete working code: expandcollapse popupGlobal $ServiceManager $ServiceManager = ObjCreate("com.sun.star.ServiceManager") $MSword = $ServiceManager.createInstance("com.sun.star.frame.Desktop") $source = "C:\test.docx" $source2 = Convert2URL($source) Global $args[3] $args[0] = MakePropertyValue("ReadOnly", False) $args[1] = MakePropertyValue("Password", "") $args[2] = MakePropertyValue("Hidden", False) $doc1 = $MSword.loadComponentFromURL($source2, "_blank", 0, $args) $ViewCursor = $doc1.CurrentController.getViewCursor() $PageStyle = $ViewCursor.PageStyleName $Style = $doc1.StyleFamilies.getByName("PageStyles").getByName($PageStyle) $PageHeight = $Style.height/100 $PageWidth = $Style.width/100 $PageOrientation = $Style.isLandscape ConsoleWrite($PageHeight & " x " & $PageWidth &@LF) ConsoleWrite("Page is landscape: " & $PageOrientation &@LF) Func MakePropertyValue($cName, $uValue) Local $Pstruc $Pstruc = $ServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue") $Pstruc.Name = $cName $Pstruc.Value = $uValue Return $Pstruc EndFunc Func Convert2URL($fname) $fname = StringReplace($fname, ":", "|") $fname = StringReplace($fname, " ", "%20") $fname = "file:///" & StringReplace($fname, "\", "/") Return $fname EndFunc Edited June 15, 2023 by Heiko mLipok 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now