Heiko Posted June 1, 2023 Share Posted June 1, 2023 Hi, I need to read the page orientation (portrait or landscape) and the page size (e.g. DIN A4) of a .docx file with Writer from LibreOffice. I can open the file with Writer, but I don't get the needed information. Can anyone help me? Link to comment Share on other sites More sharing options...
mLipok Posted June 1, 2023 Share Posted June 1, 2023 start here: and here and here: specifically here: Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
water Posted June 1, 2023 Share Posted June 1, 2023 Welcome to AutoIt and the forum! What have you tried so far? Maybe this site helps? https://wiki.documentfoundation.org/Documentation/BASIC_Guide#Formatting mLipok 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Heiko Posted June 1, 2023 Author Share Posted June 1, 2023 (edited) Hello and thanks for your help so far. I only have this code to open a docx so far. Now I just need the info which format the page has and which orientation. And I have absolutely no idea how to implement this. Global $ServiceManager Local $Desktop $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) 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 3, 2023 by Heiko Link to comment Share on other sites More sharing options...
water Posted June 1, 2023 Share Posted June 1, 2023 I haven't worked a second with LibreOffice but I think it should be possible. I suggest to have a look at the document I pointed you to and search for "Page Format". There you'll find function "IsLandscape" and the example code below sets the page size. You may need to translate the returned values from mm to DIN format. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Heiko Posted June 2, 2023 Author Share Posted June 2, 2023 But the example code is VBA and not AutoIt and I can't translate it to AutoIt. And I don't want to change the page size. I just want to read the existing page format. Link to comment Share on other sites More sharing options...
mLipok Posted June 2, 2023 Share Posted June 2, 2023 @Heiko please read: * How to post code on the forum * Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
water Posted June 2, 2023 Share Posted June 2, 2023 Don't know if this works. Add this to your code and gibve it a try. $StyleFamilies = $Doc1.StyleFamilies $PageStyles = $StyleFamilies.getByName("PageStyles") $DefPage = $PageStyles.getByName("Default") ConsoleWrite($DefPage.IsLandscape & @CRLF) ConsoleWrite($DefPage.Width & @CRLF) ConsoleWrite($DefPage.Height & @CRLF) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Heiko Posted June 6, 2023 Author Share Posted June 6, 2023 @water Thank you, but sorry, that doesn't work. I have asked ChatGPT in the meantime and got this code: ; Get the page size Local $oPageProperties = $oDocument.getPageProperties() Local $nPageWidth = $oPageProperties.Width Local $nPageHeight = $oPageProperties.Height ; Get the page orientation Local $bLandscape = $oPageProperties.IsLandscape ; Display the page size and orientation MsgBox($MB_OK, "Document Information", "Page Size: " & $nPageWidth & " x " & $nPageHeight & @CRLF & "Page Orientation: " & ($bLandscape ? "Landscape" : "Portrait")) Unfortunately it does not work either. Link to comment Share on other sites More sharing options...
mLipok Posted June 6, 2023 Share Posted June 6, 2023 (edited) 27 minutes ago, Heiko said: I have asked ChatGPT in the meantime... Unfortunately it does not work either. it didn't surprise me at all. You're asking quarter intelligence about things that require full intelligence. Would you be so nice and share the question you ask ChatGPT ? btw. take a look on my post here: Edited June 6, 2023 by mLipok Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
water Posted June 6, 2023 Share Posted June 6, 2023 @Heiko What does "it does not work" mean. Do you get an error message, no result,a wrong result ...? Please elaborate. As you are working with COM objects I suggest to add a COM error handler to your script. So we get a more detailed error description. Please check "ObjEvent" in the AutoIt help file. BTW: If you are going to reply to mLipok's ChatGPT post, please do so in the ChatGPT thread in the Chat forum. I am afraid that a thread that already contains the answer in the title ("AI is BS") does not offer any special insights. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
mLipok Posted June 6, 2023 Share Posted June 6, 2023 7 minutes ago, water said: If you are going to reply to mLipok's ChatGPT post, please do so in the ChatGPT thread in the Chat forum. I agree. Sorry to forgot mention about this. Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Heiko Posted June 7, 2023 Author Share Posted June 7, 2023 @mLipok Yes, I asked ChatGPT, because I am now absolutely desperate, because I have been trying for over 1 week and can't find a solution. I asked ChatGPT something like this: "Create an AutoIt script to open a docx file with Writer and read out page size and page orientation". I do not have permissions to see the content you posted. Link to comment Share on other sites More sharing options...
Heiko Posted June 7, 2023 Author Share Posted June 7, 2023 @water The console output with your code is: [80020009] com.sun.star.container.NoSuchElementException: Default Link to comment Share on other sites More sharing options...
water Posted June 8, 2023 Share Posted June 8, 2023 Can you please post the full code you run. There is no reference to com.sun.star.container in the code I have seen so far the full output from the SciTE output pane? We need the line number so we can tell where the error happens the full output of the COM error handler. The example provided with ObjEvent writes more lines to the console. We need this information as 0x80020009 is ageneral exception. Windows tells us that there was an error but doesn't know exactly what happened My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Heiko Posted June 13, 2023 Author Share Posted June 13, 2023 @water Sure, here is the complete code with your code snipet: expandcollapse popupGlobal $extensions[3] = ["doc","docx","odt"] Global $ServiceManager Local $Desktop $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) $StyleFamilies = $doc1.StyleFamilies $PageStyles = $StyleFamilies.getByName("PageStyles") $DefPage = $PageStyles.getByName("Default") ConsoleWrite($DefPage.IsLandscape & @CRLF) ConsoleWrite($DefPage.Width & @CRLF) ConsoleWrite($DefPage.Height & @CRLF) 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 mLipok 1 Link to comment Share on other sites More sharing options...
Mehomic Posted June 13, 2023 Share Posted June 13, 2023 (edited) Does this do what ya want? expandcollapse popup#include <MsgBoxConstants.au3> $fname = "full/path/to/your/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 $StyleFamilies = $oDoc.StyleFamilies ;< select the style families from the open document $PageStyles = $StyleFamilies.getByName("PageStyles") ;< get the page styles $DefPage = $PageStyles.getByName("Default") ;< return default page styles MsgBox($MB_SYSTEMMODAL, "RESULTS", "Is Landscape: " & $DefPage.IsLandscape & @CRLF & _ "Page Width: " & $DefPage.Width & @CRLF & _ "Page Height: " & $DefPage.Height & @CRLF) 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 Edited June 13, 2023 by Mehomic changed typo's Link to comment Share on other sites More sharing options...
Heiko Posted June 14, 2023 Author Share Posted June 14, 2023 @Mehomic I see no difference to the idea from @water but I tested it. It doesn't work: I get: The requested action with this object has failed.: $DefPage = $PageStyles.getByName("Default") $DefPage = $PageStyles^ ERROR Link to comment Share on other sites More sharing options...
Heiko Posted June 14, 2023 Author Share Posted June 14, 2023 I found a VBA code and could change it, so it works now $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) The result is e.g.: 210.01 x 297 Page is landscape: True mLipok 1 Link to comment Share on other sites More sharing options...
mLipok Posted June 14, 2023 Share Posted June 14, 2023 Complete working snippet please Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 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