Jump to content

Recommended Posts

I don't believe that option is possible with OOo because OOo's interface doesn't support it.

 

Ah, thats a disappointment...

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to post
Share on other sites
  • Replies 90
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

I decided to enhance the functionality of the OOo COM UDF found >here and >here.  Thanks to Leagnus and Andy G for providing the initial functions and framework. This UDF includes the follo

Before I upload any of the above changes, are there any other feature requests to research and implement?

64-bit update: I just upgraded to LibreOffice 5.2.0.4 x64  and it seems to work fine better. I'm still trying to get SaveAs to work properly. @keafter, I'll check out your error and see what I ca

 

BrewManNH, on 18 Dec 2013 - 8:11 PM, said:snapback.png

 I don't believe that option is possible with OOo because OOo's interface doesn't support it.snapback.png

 

If you had studied the AOO API documentation you will find that there are many 'properties' that can be utilised.

The code below originally by LEAGNUS, has been adapted by me, works just how I need.

#cs
  FileName: RunOOoCalc.au3
  Description: Run a Calc file 'hidden'
    
#ce

#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Add_Constants=y
Opt ("WinTitleMatchMode",4)
Opt("TrayIconHide", 1) ;0=show 1=hide
Opt('TrayAutoPause', 0) ;0=no pause 1=pause
#Include <Array.au3>

_Run_OOoCalc()

;===============================================================================
;
; Function Name:    _Run_OOoCalc()
; Description:      Opens a Scalc workbook and returns its object identifier.
; Parameter(s):     $fn   = full UNC File Name of the workbook file
; Requirement(s):   AutoIt3 with COM support (post 3.1.1)
;                   On Success - Returns an object variable pointing to
;                           active com.sun.star.frame.Desktop Component object
;                   On Failure  - Returns 0 and sets @ERROR = 1
; Author(s):        Leagnus
; Adapted by:       Code Mehomic (6 Jan 2011)
; Added:            The AOO API 'hidden' properties to the open spreadsheet (display 'hidden')
;===============================================================================
;
Func _Run_OOoCalc()
   Local $oDesktop, $f_num
   Local $OpenPar[2] ;<< set array
   $OpenPar[0] = _setProp("ReadOnly", False) ;<< set to true for read only
   $OpenPar[1] = _setProp("Hidden", True) ; <<-- set to false to make visible
   $oSM = Objcreate("com.sun.star.ServiceManager") ;<< create the service manager
   $oDesktop = $oSM.createInstance("com.sun.star.frame.Desktop")   ;<< create a desktop object:
   $oCurCom = $oDesktop.loadComponentFromURL( "private:factory/scalc", "_blank", 0, $OpenPar) ;<< create blank document
   if @error or Not IsObj($oCurCom) then
      SetError(1, 0, 0)
   else
      Return
 EndIf
EndFunc

;------------------------------------------------------------------------------------------
; Function Name:    setProp()
; Description:      Function to set properties of the OOo service Manager
; Requirement(s):   AutoIt3 with COM support (post 3.1.1)
;                   On Success - Returns an object variable pointing to
;                                     active com.sun.star.frame.Desktop Component object
;                   On Failure  - Returns 0 and sets @ERROR = 1
; Author(s):        Leagnus
; ----------------------------------------------------------------------------------------
 Func _setProp($cName, $uValue)
 Local $oPropertyValue
 Local $oSM, $setOOoProp
  $oSM = Objcreate("com.sun.star.ServiceManager") ;<< create the service manager
  $oPropertyValue = $oSM.Bridge_GetStruct("com.sun.star.beans.PropertyValue") ;<< create the property value
  $oPropertyValue.Name = $cName 
  $oPropertyValue.Value = $uValue
  $setOOoProp = $oPropertyValue ;<< create 'name=value' pairs
  Return $setOOoProp
EndFunc
;
; --------------------------------------- end of file ----------------------------------------------------
;

Enjoy.......

Merry Christmas and a Happy New Year to all.

Code Mehomic

Edited by Mehomic
Link to post
Share on other sites

Sorry, but I did say "I don't believe" which would imply that I wasn't sure from what I read. If there's a way to do, that's nice to know.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to post
Share on other sites

I tried simply replacing "Password" with "Hidden" in the OOoCalc UDF and that failed

This is what i tried and it failed:

Func _OOoCalcBookOpen($sFileName, $fReadOnly = False, $sHidden = True)
    Local $sFuncName = "_OOoCalcBookOpen"
    If Not IsString($sFileName) Then
        __OOoCalcErrorNotify("Error", $sFuncName, "", "$_OOoCalcStatus_InvalidDataType - File name must be a string")
        Return SetError($_OOoCalcStatus_InvalidDataType, 1, 0)
    EndIf
    If Not FileExists($sFileName) Then
        __OOoCalcErrorNotify("Error", $sFuncName, "", "$_OOoCalcStatus_NoMatch - File could not be found")
        Return SetError($_OOoCalcStatus_NoMatch, 1, 0)
    EndIf
    If Not IsBool($fReadOnly) Then
        __OOoCalcErrorNotify("Error", $sFuncName, "", "$_OOoCalcStatus_InvalidDataType - Read-only flag must be True or False")
        Return SetError($_OOoCalcStatus_InvalidDataType, 2, 0)
    EndIf
    If Not IsBool($sHidden) Then
        __OOoCalcErrorNotify("Error", $sFuncName, "", "$_OOoCalcStatus_InvalidDataType - Password must be a string")
        Return SetError($_OOoCalcStatus_InvalidDataType, 3, 0)
    EndIf
    Local $oSM = ObjCreate("com.sun.star.ServiceManager")
    If Not IsObj($oSM) Then
        __OOoCalcErrorNotify("Error", $sFuncName, "", "$_OOoCalcStatus_GeneralError - Unable to create service manager object")
        Return SetError($_OOoCalcStatus_GeneralError, 0, 0)
    EndIf
    Local $oDesktop = $oSM.createInstance("com.sun.star.frame.Desktop")
    If Not IsObj($oDesktop) Then
        __OOoCalcErrorNotify("Error", $sFuncName, "", "$_OOoCalcStatus_GeneralError - Unable to create desktop instance")
        Return SetError($_OOoCalcStatus_GeneralError, 0, 0)
    EndIf
    Local $sURL = __OOoCalcFileToURL($sFileName)
    Local $aoProperties[1] = [__OOoCalcSetPropertyValue("ReadOnly", $fReadOnly)]
    If Not IsObj($aoProperties[0]) Then
        __OOoCalcErrorNotify("Error", $sFuncName, "", "$_OOoCalcStatus_GeneralError - Unable to set read-only properties")
        Return SetError($_OOoCalcStatus_GeneralError, 0, 0)
    EndIf
        ReDim $aoProperties[2]
        Local $aoProperties[1] = [__OOoCalcSetPropertyValue("Hidden", $sHidden)]
        If Not IsObj($aoProperties[1]) Then
            __OOoCalcErrorNotify("Error", $sFuncName, "", "$_OOoCalcStatus_GeneralError - Unable to set hidden properties")
            Return SetError($_OOoCalcStatus_GeneralError, 0, 0)
        EndIf
    Local $oReturn = $oDesktop.loadComponentFromURL($sURL, "_default", 0, $aoProperties)
    If Not IsObj($oReturn) Then
        __OOoCalcErrorNotify("Error", $sFuncName, "", "$_OOoCalcStatus_GeneralError - Unable to load compoment from URL")
        Return SetError($_OOoCalcStatus_GeneralError, 0, 0)
    Else
        Return SetError($_OOoCalcStatus_Success, 0, $oReturn)
    EndIf
EndFunc   ;==>_OOoCalcBookOpen
Edited by Wombat

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to post
Share on other sites
  • 1 year later...

so far I have this UDF working easily, however when I use: _OOoCalcReadCell it is copying the formulas from the cells instead of the calculated values...

if I manually/physically (without the script) hit copy on a cell and then paste into notepad, it correctly copies the calculated value, how can i read/copy the value instead of the formula?

Edited by xekon
Link to post
Share on other sites
  • 2 weeks later...

Sorry for the delay--I don't get on here as much anymore.  There are multiple ways we could get around this.  We could change line 1380 to read ".getValue" instead of ".getFormula".  (Another option there would be to add a parameter to the function asking whether to read formula or value.)  We could also use _OOoCalcReadSheetToArray to read the value(s).

Additional feedback would help to decide how to move forward if I'm to update any functions.

Edited by GMK
clarification
Link to post
Share on other sites

... Additional feedback would help to decide how to move forward if I'm to update any functions.

What is the need for Func _OOoCalcBookNew() to create a default sheet as ReadOnly ?
I had to change that to have a functional demo.
A small change like Func _OOoCalcBookNew( $fReadOnly = False ) would be better :)

Thanks for putting this together and do continue if you have the time :D

 

Link to post
Share on other sites

rather script breaking change

just FunctionNames renaming 

_OOoCalc_BookNew
_OOoCalc_BookOpen
_OOoCalc_BookAttach
_OOoCalc_BookSaveAs
_OOoCalc_BookClose
_OOoCalc_WriteCell
_OOoCalc_WriteFormula
_OOoCalc_WriteFromArray
_OOoCalc_HyperlinkInsert
_OOoCalc_RangeMoveOrCopy
_OOoCalc_CreateBorders
_OOoCalc_NumberFormat
_OOoCalc_ReadCell
_OOoCalc_ReadSheetToArray
_OOoCalc_RowDelete
_OOoCalc_ColumnDelete
_OOoCalc_RowInsert
_OOoCalc_ColumnInsert
_OOoCalc_SheetAddNew
_OOoCalc_SheetDelete
_OOoCalc_SheetNameGet
_OOoCalc_SheetNameSet
_OOoCalc_SheetList
_OOoCalc_SheetActivate
_OOoCalc_SheetSetVisibility
_OOoCalc_SheetMove
_OOoCalc_SheetPrint
_OOoCalc_HorizontalAlignSet
_OOoCalc_FontSetProperties
_OOoCalc_CellSetColors
_OOoCalc_RowSetColors
_OOoCalc_ColumnSetColors
_OOoCalc_RowSetProperties
_OOoCalc_ColumnSetProperties
_OOoCalc_FindInRange
_OOoCalc_ReplaceInRange
_OOoCalc_ErrorHandlerRegister
_OOoCalc_ErrorHandlerDeRegister

 

EDIT: But this should wait for any other bigger changes like rewrite.

 

Edited 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 * 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 APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

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 TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE *

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 stuffOnHungApp handlerAvoid "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"
:naughty:  :ranting:, 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: 2021-10-18

Link to post
Share on other sites

Does this work for anybody with 64-bit LibreOffice5?

I have 64-bit Win10 + 64-bit LO and connection doesnt work. 64-bit Win10 + 32-bit LO works perfectly.

Problem may be in com.sun.star.ServiceManager DCOM, which is apparently run by 64bit soffice.exe and, as I understand, cant be reached by 32bit AutoIt, even if I use 64bit Script Runner.

I experimented with adding com.sun.star.ServiceManager into WOW6432Node parts of registy, but with no luck.

Any comments?

 

 

 

Link to post
Share on other sites
  • 6 months later...

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 * 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 APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) *

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 TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE *

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 stuffOnHungApp handlerAvoid "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"
:naughty:  :ranting:, 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: 2021-10-18

Link to post
Share on other sites
  • 2 weeks later...

Dates don't play nicely. It adds a ' in front of the date rendering it useless.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <OOoCalc.au3>

$Form1_1 = GUICreate("Notary Client Verification Form", 667, 273, 192, 132)
$Date1 = GUICtrlCreateDate(_DateToDayValue, 72, 40, 257, 25,$WS_TABSTOP)
$Button1 = GUICtrlCreateButton("OK", 8, 206, 649, 57)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $TheDate = GUICtrlRead($Date1)
            MsgBox(0,"",$TheDate)
            $OOspreadsheet = _OOoCalcBookNew()
            _OOoCalcBookSaveAs($OOspreadsheet,"C:\new.ods")
            _OOoCalcBookClose($OOspreadsheet)
            $OOspreadsheet = _OOoCalcBookOpen("C:\new.ods")
            Sleep(1000)
            _OOoCalcWriteCell($OOspreadsheet,$TheDate,"A1")
    EndSwitch
WEnd

Run and click ok to see error.

Link to post
Share on other sites

64-bit update: I just upgraded to LibreOffice 5.2.0.4 x64  and it seems to work fine better. I'm still trying to get SaveAs to work properly.

@keafter, I'll check out your error and see what I can find. What version of OO/LO are you running?

Edited by GMK
Additional clarification needed; OK, maybe not fine, but better.
Link to post
Share on other sites

I'm working on updating the _OOoCalcWriteCell functions, as well as the constants for _OOoCalcNumberFormat, which don't seem to match the documentation.

In the meantime, you can use _OOoCalcWriteFormula, then use _OOoCalcNumberFormat to format the cell as a date.

Edited by GMK
Mistyped function name.
Link to post
Share on other sites
On 8/4/2016 at 1:56 AM, keafter said:

Dates don't play nicely. It adds a ' in front of the date rendering it useless.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <OOoCalc.au3>

$Form1_1 = GUICreate("Notary Client Verification Form", 667, 273, 192, 132)
$Date1 = GUICtrlCreateDate(_DateToDayValue, 72, 40, 257, 25,$WS_TABSTOP)
$Button1 = GUICtrlCreateButton("OK", 8, 206, 649, 57)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $TheDate = GUICtrlRead($Date1)
            MsgBox(0,"",$TheDate)
            $OOspreadsheet = _OOoCalcBookNew()
            _OOoCalcBookSaveAs($OOspreadsheet,"C:\new.ods")
            _OOoCalcBookClose($OOspreadsheet)
            $OOspreadsheet = _OOoCalcBookOpen("C:\new.ods")
            Sleep(1000)
            _OOoCalcWriteCell($OOspreadsheet,$TheDate,"A1")
    EndSwitch
WEnd

Run and click ok to see error.

Update (see first post) and try this:

#include "OOoCalc.au3"
#include <Date.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

_OOoCalc_ComErrorHandler_UserFunction(_ErrFunc)

$Form1_1 = GUICreate("Notary Client Verification Form", 667, 273, 192, 132)
$Date1 = GUICtrlCreateDate(_DateToDayValue, 72, 40, 257, 25, $WS_TABSTOP)
$Button1 = GUICtrlCreateButton("OK", 8, 206, 649, 57)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $TheDate = GUICtrlRead($Date1)
            MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, "Date", $TheDate)
            $sFileName = @MyDocumentsDir & "\new.ods"
            If FileExists($sFileName) Then FileDelete($sFileName)
            $OOspreadsheet = _OOoCalc_BookNew()
            Sleep(1000)
            _OOoCalc_WriteCell($OOspreadsheet, $TheDate, "A1")
            _OOoCalc_NumberFormat($OOspreadsheet, 36, "A1")
            _OOoCalc_BookSaveAs($OOspreadsheet, $sFileName)
            _OOoCalc_BookClose($OOspreadsheet)
            $OOspreadsheet = _OOoCalc_BookOpen($sFileName)
    EndSwitch
WEnd

; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

 

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Hermes
      Hi, I am struggling in setting the value of a textarea based on the value of clipboard (that contains a long web page source codes). If I use _WD_SetElementValue, it freezes after some time, or appears to be pressing tab and goes out of focus. I can also use send keys but i need the script to run in the background.
      Here is the full script:
      #Include "Chrome.au3" #Include "wd_core.au3" #Include "wd_helper.au3" #Include "WinHttp.au3" #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <Array.au3> #include <AutoItConstants.au3> #include <WinAPIFiles.au3> #include <GDIPlus.au3> #include <Excel.au3> Local $sDesiredCapabilities, $sSession SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_LoadWait($sSession) _WD_Navigate($sSession, "http://demo.borland.com/testsite/stadyn_largepagewithimages.html") _WD_LoadWait($sSession) Global $sSource = _WD_GetSource($sSession) Local $Paste = ClipPut($sSource) Local $sData = ClipGet() Local $aArray = 0, _ $iOffset = 1 While 1 $aArray = StringRegExp($sData, '(?s)<p>.*</p>', $STR_REGEXPARRAYMATCH, $iOffset) If @error Then ExitLoop $iOffset = @extended For $i = 0 To UBound($aArray) - 1 Local $Paste = ClipPut($aArray[$i]) Local $sRegExData = ClipGet() ;MsgBox(0, "", "$sRegExData = " & $sRegExData) Next WEnd _WD_Navigate($sSession, "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_textarea_placeholder") _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, "iframe#iframeResult") Local $sElement1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "iframe#iframeResult") _WD_FrameEnter($sSession, $sElement1) _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/textarea") $textarea = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//html/body/textarea") _WD_ElementAction($sSession, $textarea, 'click') ;WD SetElementValue(SsSession, Stextarea, $sRegExData) <-- I can do this but the focus goes out, or the browser freezes _WD_FrameLeave($sSession) sleep(2000) Send("^v") _WD_LoadWait($sSession) _WD_Shutdown() Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}' EndFunc ;==>SetupChrome Can someone help me please, or re-direct me to the right path? TIA!
    • By Hermes
      Hi, I am trying to select elements in print page (dialog window) for a specific web page. But when trying to do so, it looks like it does not allow me to do it.
      So far, this is what I have:
      _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, "body") Local $mainpagebody = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "body") _WD_HighlightElement($sSession, $mainpagebody, 2) _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, "img.print-button") Local $printbutton = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "img.print-button") _WD_ElementAction($sSession, $printbutton, 'click') _WD_LoadWait($sSession) Sleep(3000) _WD_WaitElement($sSession, $_WD_LOCATOR_ByCSSSelector, "body") Local $printpagebody = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "body") _WD_HighlightElement($sSession, $printpagebody, 2) The script above highlights the main web page "body" element, then clicks a tag to print a specific part of the page, then it will open a print page window where i am trying to highlight the body of that print page - but it looks like it is dropping from the session because it opens up another chrome page chrome://print.
       
      Below is the output log:
      __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"body"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}} _WD_WaitElement ==> Success __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"body"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/execute/sync; $sData={"script":"arguments[0].style='background: #FFFF66; border-radius: 5px; padding-left: 3px;'; return true;", "args":[{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}]} __WD_Post: StatusCode=200; ResponseText={"value":true}... _WD_ExecuteScript: {"value":true}... __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"img.print-link"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}} _WD_WaitElement ==> Success __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"img.print-link"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element/eb9e4673-4dec-4d4c-be6a-b7967743394b/click; $sData={"id":"eb9e4673-4dec-4d4c-be6a-b7967743394b"} __WD_Post: StatusCode=200; ResponseText={"value":null}... _WD_ElementAction: {"value":null}... __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/execute/sync; $sData={"script":"arguments[0].style='background: #FFFF66; border-radius: 5px; padding-left: 3px;'; return true;", "args":[{"element-6066-11e4-a52e-4f735466cecf":"eb9e4673-4dec-4d4c-be6a-b7967743394b"}]} __WD_Post: StatusCode=200; ResponseText={"value":true}... _WD_ExecuteScript: {"value":true}... __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/execute/sync; $sData={"script":"return document.readyState", "args":[]} __WD_Post: StatusCode=500; ResponseText={"value":{"error":"script timeout","message":"script timeout\n (Session info: chrome=92.0.4515.107)... __WD_Post ==> Webdriver Exception: {"value":{"error":"script timeout","message":"script timeout\n (Session info: chrome=92.0.4515.107)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00C63733+2504499]\n\tOrdinal0 [0x00BFC401+2081793]\n\tOrdinal0 [0x00B024F0+1058032]\n\tOrdinal0 [0x00B55685+1398405]\n\tOrdinal0 [0x00B45E83+1334915]\n\tOrdinal0 [0x00B54CDB+1395931]\n\tOrdinal0 [0x00B45D4B+1334603]\n\tOrdinal0 [0x00B222B4+1188532]\n\tOrdinal0 [0x00B23149+1192265]\n\tGetHandleVerifier [0x00DDFB8C+1512252]\n\tGetHandleVerifier [0x00E8B0DF+2214031]\n\tGetHandleVerifier [0x00CE4BC3+484211]\n\tGetHandleVerifier [0x00CE3E69+480793]\n\tOrdinal0 [0x00C0218D+2105741]\n\tOrdinal0 [0x00C066E8+2123496]\n\tOrdinal0 [0x00C06827+2123815]\n\tOrdinal0 [0x00C0FB73+2161523]\n\tBaseThreadInitThunk [0x75EB62C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77C11B69+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77C11B34+1028]\n"}} _WD_ExecuteScript: {"value":{"error":"script timeout","message":"script timeout\n (Session info: chrome=92.0.4515.107)... _WD_ExecuteScript ==> Webdriver Exception: HTTP status = 500 _WD_LoadWait ==> Webdriver Exception __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"body"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}} _WD_WaitElement ==> Success __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/element; $sData={"using":"css selector","value":"body"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}}... _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/cd08704233a965ccbaf9292e8692c3e4/execute/sync; $sData={"script":"arguments[0].style='background: #FFFF66; border-radius: 5px; padding-left: 3px;'; return true;", "args":[{"element-6066-11e4-a52e-4f735466cecf":"91a394f0-004c-480d-aedf-52e2b30233c6"}]} __WD_Post: StatusCode=200; ResponseText={"value":true}... _WD_ExecuteScript: {"value":true}...  
      Is it even possible to select elements in print page?

    • By walec
      Hello
      How can I export a sheet to pdf using the OOoCalc.au3 UDF?
      Thank you for any hints or possibly other solutions / functions.
    • By p4sCh
      Hello everyone,
      I've created a UDF for basic communication with SSH servers. I know there is already such a UDF, but I wasn't satisfied with it for my purpose, so I created a new one.
      This UDF also acts as a wrapper for the plink executable. Its essential functions are _SSHConnect, _SSHSend, _SSHRecv and _SSHCloseSocket.
      It does support multiple simultaneous connections and aims to be pretty robust. Feel free to share your opinions
      Two of the included examples use a slightly modified version of Vintage Terminal by @Chimp
      Download
      The download includes ssh.au3 (UDF), plink.exe (necessary), vintage terminal and code examples:
      Version 1.0.1
      - fixed rare _SSHConnect bug where "ssh-host-key prompt" was not answered
      SSH UDF 1.0.1.zip
       
    • By water
      I have started to rewrite the PowerPoint UDF similar to the Word, Excel and Outlook UDF. The new UDF will not be compatible with the existing one.
      I will add examples, documentation, a section in the wiki etc.
      So far the following functions have been coded - more are on the ToDo list.
      _PPT_Open: Open a connection to a running instance of PowerPoint or start a new one _PPT_Close: Close a PowerPoint instance _PPT_CommentAdd: Add a Comment anywhere on a Slide or connected to a Shape (version 1.5.0.0 2021-08-31) _PPT_CommentDelete: Delete a single Comment from a Slide or all Comments from a SlideRange (version 1.5.0.0 2021-08-31) _PPT_CommentList: Get a list of all Comments in a Presentation (version 1.5.0.0 2021-08-31) _PPT_ConvertUnits: Convert units (like centimeters) to other units (like points) (version 1.3.0.0 2021-08-17) _PPT_HeaderFooterList: Returns a list of Headers and Footers for a Presentation (version 1.1.0.0 2021-07-25, removed with version 1.4.0.0 2021-08-25) _PPT_HeaderFooterSet: Sets the Header/Footer for a Slide/Slides or the Slide-/Notes-/Handout-/Title-Master of the Presentation (version 1.2.0.0 2021-08-09) _PPT_PresentationAttach: Attach to an already opened Presentation _PPT_PresentationClose: Close a Presentation _PPT_PresentationExport: Export one/multiple/all Slides as PDF or XPS. _PPT_PresentationExportGraphic: Export one/multiple/all Slides in a graphic format. _PPT_PresentationList: Returns a list of currently open Presentations (version 1.0.0.0 2021-07-20) _PPT_PresentationNew: Create a new Presentation _PPT_PresentationOpen: Open an existing Presentation _PPT_Print: Print one/multiple/all Slides of a Presentation (version 1.0.0.0 2021-07-20) _PPT_PresentationSave: Save a Presentation _PPT_PresentationSaveAs: Save a Presentation to another location or with another type _PPT_ShapeAdd: Add a Shape to a single or multiple Slides (version 1.1.0.0 2021-07-25) _PPT_ShapeAlignDistribute: Aligns and distributes the Shapes in the specified ShapeRange (version 1.6.0.0 - to be released) _PPT_ShapeCopyMove: Copy/move a Shape(s) of a single Slide to a Slide(s) in the same or a different Presentation (version 1.1.0.0 2021-07-25) _PPT_ShapeDelete: Delete a Shape or Shapes from a single or multiple Slides (version 1.1.0.0 2021-07-25) _PPT_SlideAdd: Add slide(s) to a Presentation _PPT_SlideCopyMove: Copy, move, duplicate Slide(s) _PPT_SlideDelete: Delete Slide(s) _PPT_SlideShow: Show a Presentation _PPT_TableGet: Extract data from a PowerPoint Table Shape to an array (version 1.3.0.0 2021-08-17) _PPT_TableSet: Write data to a PowerPoint Table Shape (version 1.3.0.0 2021-08-17) _PPT_TextFindReplace: Find & replace text throughout entire PowerPoint presentation (version 1.0.0.0 2021-07-20) _PPT_TextSet: Sets/modifies the Text of a Shape or Shapes of a single or multiple Slides (version 1.2.0.0 2021-08-09 Which functions do you want me to add to the UDF?
      ToDo list:
      create slide (JLogan3o13) - Done: _PPT_SlideAdd Apply template to slide (JLogan3o13) - Done: _PPT_SlideAdd Apply theme to slide (JLogan3o13) Cut/Copy/Duplicate/Move/Delete slide(s) (JLogan3o13) - Done: _PPT_SlideCopyMove, _PPT_SlideDelete Export slides (JLogan3o13) - Done: _PPT_PresentationExport Cut/Copy/Duplicate/Move/Delete shape(s) (JLogan3o13): Done : _PPT_ShapeCopyMove, _PPT_ShapeDelete (version 1.1.0.0 2021-07-25) ApplyAnimation, Select, SetDefaultProperties, and zOrder for shape(s) (JLogan3o13) Searching and replacing text (pcjunki) - Done: _PPT_TextFindReplace (version 1.0.0.0 2021-07-20) Export slides in a graphic format (JPG, GIF, PNG ...) (UEZ) - Done: _PPT_PresentationExportGraphic The UDF can be downloaded from the download forum.
       
×
×
  • Create New...