Jump to content

Recommended Posts

  • 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

Hmm I'm not sure how I'm getting this error, but from what I can tell it appears that having existing calc window(s) open causes the BookAttach to error. It's odd however because I can have both open and perform 1 function that enters and edits 1 sheet while the other is open, then press a button a little later and have another function edit the other sheet while the 1st sheet is open. Essentially both sheets are open the whole time, but waiting a while before editing each doesn't produce the error.

AutoBookKeeping.au3 (183) : ==> COM Error intercepted !
    err.number is:      0x80020009
    err.windescription: Exception occurred.

    err.description is:     com.sun.star.lang.IllegalArgumentException: URL seems to be an unsupported one.
    err.source is:      [automation bridge] 
    err.helpfile is:    
    err.helpcontext is:     0
    err.lastdllerror is:    0
    err.scriptline is:  183
    err.retcode is:     0x000003E9

My best guess is that the open office COM gets held up if you have 2 open at the same time. Is there a way that I can attach and then detach without closing the sheets? 1 Sheet is really large and takes a long time to load, the other I could close out of each time. However, even leaving the large sheet open and closing out of the faster sheet, still seems to cause that error.

Ugh that feels like a really vague explanation. My car is making funny noises, fix it somehow. Please feel free to ask clarifying questions. I would include code, but isolating it to work for a quick example may not produce the same results and it's sensitive to my moms work. If you, as the dev for this, would like to take a closer look at all the code and spreadsheets involved lemme know. Send me an email in a private message and I'll send it on over.

Edit So running through your code I took

Func _OOoCalc_BookOpen($sFileName, $bHidden = False, $bReadOnly = False, $sPassword = '')
    Local $oOOoCalc_COM_ErrorHandler = ObjEvent("AutoIt.Error", __OOoCalc_ComErrorHandler_InternalFunction)
    #forceref $oOOoCalc_COM_ErrorHandler
    If Not IsString($sFileName) Then Return SetError($_OOoCalcStatus_InvalidDataType, 1, 0)
    If Not FileExists($sFileName) Then Return SetError($_OOoCalcStatus_NoMatch, 1, 0)
    If Not IsBool($bHidden) Then Return SetError($_OOoCalcStatus_InvalidDataType, 2, 0)
    If Not IsBool($bReadOnly) Then Return SetError($_OOoCalcStatus_InvalidDataType, 3, 0)
    If Not IsString($sPassword) Then Return SetError($_OOoCalcStatus_InvalidDataType, 4, 0)
    Local $oSM = ObjCreate("com.sun.star.ServiceManager")
    If Not IsObj($oSM) Then Return SetError($_OOoCalcStatus_GeneralError, 0, 0)
    Local $oDesktop = $oSM.createInstance("com.sun.star.frame.Desktop")
    If Not IsObj($oDesktop) Then Return SetError($_OOoCalcStatus_GeneralError, 0, 0)
    Local $sURL = __OOoCalc_FileToURL($sFileName)
    Local $aoProperties[2] = [__OOoCalc_SetPropertyValue('Hidden', $bHidden)]
    If Not IsObj($aoProperties[0]) Then Return SetError($_OOoCalcStatus_GeneralError, 2, 0)
    $aoProperties[1] = __OOoCalc_SetPropertyValue('ReadOnly', $bReadOnly)
    If Not IsObj($aoProperties[1]) Then Return SetError($_OOoCalcStatus_GeneralError, 3, 0)
    If $sPassword <> '' Then
        ReDim $aoProperties[2]
        $aoProperties[1] = __OOoCalc_SetPropertyValue('Password', $sPassword)
        If Not IsObj($aoProperties[1]) Then Return SetError($_OOoCalcStatus_GeneralError, 4, 0)
    EndIf
    Local $oReturn = $oDesktop.loadComponentFromURL($sURL, '_default', 0, $aoProperties)
    If Not IsObj($oReturn) Then Return SetError($_OOoCalcStatus_GeneralError, 1, 0)
    EndIf
    Return SetError($_OOoCalcStatus_Success, 0, $oReturn)

and added

MsgBox(0,"try",$sURL)
    Local $oReturn = $oDesktop.loadComponentFromURL($sURL, '_default', 0, $aoProperties)
    If Not IsObj($oReturn) Then
        MsgBox(0,"fail",$sURL)
        Return SetError($_OOoCalcStatus_GeneralError, 1, 0)
    EndIf
    Return SetError($_OOoCalcStatus_Success, 0, $oReturn)

a couple msgbox's so I could see what I'm passing into it. First message box for the first spreadsheet gives:

---------------------------
try
---------------------------
file:///C|/Users/Jacob/Desktop/Jake's%20icons/autoit-v3/install/AutoBookKeeping/Notary%20Client%20Verification%20spreadsheet.ods
---------------------------
OK   
---------------------------

Which is the first smaller and faster sheet. Second is:

---------------------------
try
---------------------------
file:///C|/Users/Jacob/Desktop/Connie%202016%20Notary.ods
---------------------------
OK   
---------------------------

Which is the larger slower sheet. Then entering the error reporter:

---------------------------
fail
---------------------------
file:///C|/Users/Jacob/Desktop/Connie%202016%20Notary.ods
---------------------------
OK   
---------------------------

Which I've pretty well concluded that this information is useless. I assume that "file:///C|" is valid since it works for the first sheet. Maybe the ' in Jake's Icons is causing an error... brb hmm nope... Got to somehow be about an amount of time in between opening and closing sheets with the COM. Any help would be greatly appreciated.

It appears that perhaps https://www.openoffice.org/api/docs/common/ref/com/sun/star/frame/FrameSearchFlag.html Auto is not supported anymore. Ie:

Local $oReturn = $oDesktop.loadComponentFromURL($sURL, '_default', 0, $aoProperties)

Should be:

Local $oReturn = $oDesktop.loadComponentFromURL($sURL, '_default', 55, $aoProperties)

I could very easily be barking up the wrong tree though. Brb I'm going to test that. Nope.

Edited by keafter
Link to post
Share on other sites

@keafter: Are you saying that if multiple sheets are open, you can attach to one, but not the other?  I don't know if this would help, but would populating data from one book to an array eliminate the need to keep both open, or are you editing both at the same time? If it's possible to create a simple reproducer, that might help.

Edit: Are you able to open each of those files individually without the other open?  I'm trying to troubleshoot all options here.  Maybe one of the files opens, but not the other, which could point to a problem with __OOoCalc_FileToURL or my loadComponentFromURL command(s).

@rollo5: I'm not sure if this would work with the portable version, since it uses UNO/COM.

The objects that this UDF uses are as follows:
com.sun.star.ServiceManager
com.sun.star.frame.Desktop
com.sun.star.text.TextField.URL

Anyone else can feel free to correct me if I'm wrong, but I believe that if those aren't in your registry, this UDF is a "no go."

Edited by GMK
Addendum
Link to post
Share on other sites

Hey lucky me! I remembered that I had a file made that excludes sensitive info. Please inform me if this zip contains any sensitive info... shouldn't

So the script is AutoBookKeeping.au3

1st. Open both Job database.ods and Notary Client Verification.ods

2nd. Run the AutoBookKeeping script. Will probably need firefox so it doesn't kill over.

3rd. Click OK and watch for errors. It will start by editing Notary Client Verification.ods then close and print that, then open firefox for directions, then edit Job database. It errors opening/attaching to job database.ods

Optional 4th. Button labeled Just print Notary Client verification will just edit the first spreadsheet. Button labeled Just update Spreadsheet will edit job database.ods 

The function that edits Notary Client Verification.ods is called NCV() which starts on line 321 The other is Signings() which starts on 382.

You press one button and then wait and press the other and it works, but for some reason it doesn't like doing both immediately side by side. Comment or uncomment line 362 to keep it from closing  or close the Notary Client Verification.ods. Comment or uncomment line 438 for the Job database.ods.

It's pretty messy code... I'll do some house cleaning and optimizing eventually lol.

Testing.zip

Edited by keafter
Link to post
Share on other sites

@GMK

Dang actually that wasn't it. I also tried changing it to  _OOoCalc_BookSaveAs($openofficecalcwindow, $NCVFolderToSave & $NCVFileName, Default, True)

but that didn't work either.

AutoBookKeeping.au3 (183) : ==> COM Error intercepted !
    err.number is:      0x80020009
    err.windescription: Exception occurred.

    err.description is:     com.sun.star.lang.IllegalArgumentException: URL seems to be an unsupported one.
    err.source is:      [automation bridge] 
    err.helpfile is:    
    err.helpcontext is:     0
    err.lastdllerror is:    0
    err.scriptline is:  183
    err.retcode is:     0x000003E9

Edit: I think my error is while trying to attach to the already open file and then when it fails to attach to the file it tries to open the already open file.

$OoCalcWindow2 = _OOoCalc_BookAttach($ReportSpreadsheetFile)
If @error Then
    $OoCalcWindow2 = _OOoCalc_BookOpen($ReportSpreadsheetFile)
EndIf

Sure enough so in your _OOoCalc_BookAttach at the bottom I've done this:

Local $sWinTitle = WinGetTitle('[CLASS:SALFRAME]')
    MsgBox(0,"title is",$sWinTitle)
    Local $asTempTitle = StringRegExp($sWinTitle, '(.*?\.[A-z]{3}).*', 1)
    MsgBox(0,"title is",$asTempTitle[0])
    If Not @error Then $sWinTitle = $asTempTitle[0]
    If Not StringInStr($sWinTitle, $sFileName) Then
        MsgBox(0,"error","File not same as filename")
        MsgBox(0,"",$sWinTitle & " " & $sFileName)
        Return SetError($_OOoCalcStatus_NoMatch, 0, 0)
    EndIf
    Local $oReturn = $oDesktop.getCurrentComponent
    If Not IsObj($oReturn) Then Return SetError($_OOoCalcStatus_GeneralError, 0, 0)
    Return SetError($_OOoCalcStatus_Success, 0, $oReturn)
EndFunc   ;==>_OOoCalc_BookAttach

The "If Not StringInStr" is coming up true even though the MsgBox(0,"",$sWinTitle & " " & $sFileName) gives:

---------------------------

---------------------------
Connie 2016 Notary.ods C:\Users\Jacob\Desktop\Connie 2016 Notary.ods
---------------------------
OK   
---------------------------

That string is however in that string. So why does it error?

I swapped stringinstr around so it's: StringInStr($sFileName, $sWinTitle) and I get passed that error. However it's still erroring on:

If Not IsObj($oReturn) Then Return SetError($_OOoCalcStatus_GeneralError, 0, 0)

This actually leaves me at the point where I can either have both closed or both open and it still detects both as objects while opening or attaching. This is partially solved, but, for some reason if I have 1 open and 1 closed it doesn't detect the 1 open as an object. I imagine that most of the time 1 will be left open when she runs this script which wouldn't be good.

Hmm I also have to send just the filename through the attach function instead of the full file path and filename or it produces similar errors:

_OOoCalc_BookAttach("Notary Client Verification spreadsheet.ods")
Instead of
_OOoCalc_BookAttach("C:/Users/Jacob/Desktop/Notary Client Verification spreadsheet.ods")

 

Edited by keafter
Link to post
Share on other sites
  • 2 months later...

Hey it's me again! It's legitimately taken me this long to decide to revisit this. I have finally gotten around to making my Mom's spreadsheet easily sortable without botching up existing formulas. (For those curious, I'll add how at the bottom of this) 

Ultimately I'm trying to make my spreadsheet usable by the average joe, by including an autoit script to manage the quirks.

So for the record @GMK I already love you forever for helping figure out the double spreadsheet problem I was having. I would love you forever x2 if you managed to get the _OOoCalc_RangeSort working. :D (Thought that I would say that it would be useful to someone :) )

 

Making a spreadsheet sortable without messing up formulas can be a pain in open office at times. You may want to sort a table of info, but your formulas seem to still calculate where they were prior to sorting. This isn't good because then you have to go back and fix all the effected formulas. Luckily in my case all of the formulas follow row numbers:

=IF($Signings.$K6>0;$Signings.$J6;"")
=IF($Signings.$K7>0;$Signings.$J7;"")
=IF($Signings.$K8>0;$Signings.$J8;"")
etc.

Essentially to make the formulas sort properly without becoming jumbled you just make all of the formulas the same. How would you do such things and still keep info? Simple:

=INDIRECT("$'Formulas Configurations'.$C" & ROW())

On a separate sheet match up the rows exactly and put your list of formulas on that sheet. Then call the value of the cell from the other sheet with the row number of the sheet you want to sort. Finangling! 

 

So essentially because it has been set up this way, I can sort all day long without fearing my formulas getting jumbled. This means that I could actually make the _OOoCalc_RangeSort work in a much safer manner, perfect even for testing. :) 

This was written up quickly and with a foggy brain, so if it doesn't make much sense, I totally understand and I'll try to clarify as needed.

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

Hi @keafter,

Sorry it's taken me so long to get back on here.  Unfortunately, I have not found the best way to get the sort to work.  I haven't looked at it in a while, but perhaps I can find something after taking a (long) break from it.  If I do get it working, I'll be sure to post an updated version here.  If anyone else finds the secret to sorting in OpenOffice/LibreOffice using UNO, please let me know!

Link to post
Share on other sites

GMK please use ByRef here:
 

__OOoCalc_ComErrorHandler_InternalFunction(ByRef $oCOMError)

 

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

if you are using "changed" functions from other UDF  please make function names more unique.

;__DateTimeSplit
;__DateIsValid
;__DaysInMonth
;__DateIsLeapYear

for example change them to:

;__OOoCalc__DateTimeSplit
;__OOoCalc__DateIsValid
;__OOoCalc__DaysInMonth
;__OOoCalc__DateIsLeapYear

as this is quite possible that another developer do the same, and will be a FunctionName conflict.

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

In relation to : _OOoCalc_RangeSort()

I found this example:

https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Sorting

 // --- sort by second column, ascending ---
 
  // define the fields to sort
  com.sun.star.util.SortField[] aSortFields = new com.sun.star.table.TableSortField[1];
  aSortFields[0] = new com.sun.star.table.TableSortField();
  aSortFields[0].Field = 1;
  aSortFields[0].IsAscending = true;
  aSortFields[0].IsCaseSensitive = false;
 
  // define the sort descriptor
  com.sun.star.beans.PropertyValue[] aSortDesc = new com.sun.star.beans.PropertyValue[2];
  aSortDesc[0] = new com.sun.star.beans.PropertyValue();
  aSortDesc[0].Name = "SortFields";
  aSortDesc[0].Value = aSortFields;
  aSortDesc[1] = new com.sun.star.beans.PropertyValue();
  aSortDesc[1].Name = "ContainsHeader";
  aSortDesc[1].Value = new Boolean(true);
 
  // perform the sorting
  com.sun.star.util.XSortable xSort = (com.sun.star.util.XSortable)
      UnoRuntime.queryInterface(com.sun.star.util.XSortable.class, xRange);
  xSort.sort(aSortDesc);

I think you are properly define field to sort, and sort descriptor.
But I do not see how you are using this implementation:

  // perform the sorting
  com.sun.star.util.XSortable xSort = (com.sun.star.util.XSortable)
      UnoRuntime.queryInterface(com.sun.star.util.XSortable.class, xRange);
  xSort.sort(aSortDesc);

but for the other look here:

https://wiki.openoffice.org/wiki/Documentation/OOo3_User_Guides/Calc_Guide/Sorting

Sub SortRange
  Dim oSheet        ' Calc sheet containing data to sort.
  Dim oCellRange    ' Data range to sort.
 
  REM An array of sort fields determines the columns that are
  REM sorted. This is an array with two elements, 0 and 1.
  REM To sort on only one column, use:
  REM Dim oSortFields(0) As New com.sun.star.util.SortField
  Dim oSortFields(1) As New com.sun.star.util.SortField
 
  REM The sort descriptor is an array of properties.
  REM The primary property contains the sort fields.
  Dim oSortDesc(0) As New com.sun.star.beans.PropertyValue
 
  REM Get the sheet named "Sheet1"
  oSheet = ThisComponent.Sheets.getByName("Sheet1")
 
  REM Get the cell range to sort
  oCellRange = oSheet.getCellRangeByName("A1:C5")
 
  REM Select the range to sort.
  REM The only purpose would be to emphasize the sorted data.
  'ThisComponent.getCurrentController.select(oCellRange)
 
  REM The columns are numbered starting with 0, so
  REM column A is 0, column B is 1, etc.
  REM Sort column B (column 1) descending.
  oSortFields(0).Field = 1
  oSortFields(0).SortAscending = FALSE
 
  REM If column B has two cells with the same value,
  REM then use column A ascending to decide the order.
  oSortFields(1).Field = 0
  oSortFields(1).SortAscending = True
 
  REM Setup the sort descriptor.
  oSortDesc(0).Name = "SortFields"
  oSortDesc(0).Value = oSortFields()
 
  REM Sort the range.
  oCellRange.Sort(oSortDesc())
End Sub 

 

It looks good, so currently I cant find solution for this sorting issue.

 


here is my proposal for:

Func __OOoCalc_WorksheetIsValid($oObj, $vSheet)
    Local $oOOoCalc_COM_ErrorHandler = ObjEvent("AutoIt.Error", __OOoCalc_ComErrorHandler_InternalFunction)
    #forceref $oOOoCalc_COM_ErrorHandler
    If Not IsObj($oObj) Then Return SetError($_OOoCalcStatus_GeneralError, 0, 0)
    If IsInt($vSheet) Then
        If $vSheet >= 0 And $vSheet <= $oObj.getSheets.count - 1 Then Return SetError($_OOoCalcStatus_Success, 0, True)
        Return SetError($_OOoCalcStatus_NoMatch, 0, False)
    ElseIf IsString($vSheet) And $vSheet <> '' Then
        Local $asWorksheets = _OOoCalc_SheetList($oObj)
        For $iSheet = 1 To $asWorksheets[0]
            If $asWorksheets[$iSheet] == $vSheet Then Return SetError($_OOoCalcStatus_Success, 0, True)
        Next
        Return SetError($_OOoCalcStatus_NoMatch, 0, False)
    EndIf
    Return SetError($_OOoCalcStatus_InvalidDataType, 0, False)
EndFunc   ;==>__OOoCalc_WorksheetIsValid

Remark 1: you do not need to declare $iSheet as this is done autmaticaly by For Next Loop

Remark 2: you can start using Scoping for $asWokrsheets (can be declared only when IsString .... )

 

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

I notice that this part:
 

; Don't understand why the sort is not working
For $iCounter = 2 To 6
    _OOoCalc_RangeSort($oCalc, "CALC", "B3:F6", $iCounter, True, True)
    MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, $sTitle, "B3:F6 Sorted by column " & Chr($iCounter + 64) & " (ascending)...")
Next

Currently works well :)

Tested on Apache OpenOffice 4.1.1

 

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

Constants:

Global Enum _ ; @Extended Status Types
        $0CALC_EXT_DEFAULT, _
        $0CALC_EXT_PARAM1, _
        $0CALC_EXT_PARAM2, _
        $0CALC_EXT_PARAM3, _
        $0CALC_EXT_PARAM4, _
        $0CALC_EXT_PARAM5, _
        $0CALC_EXT_COUNTER

and small fix and refactoring

Func __OOoCalc_WorksheetIsValid($oObj, $vSheet)
    Local $oOOoCalc_COM_ErrorHandler = ObjEvent("AutoIt.Error", __OOoCalc_ComErrorHandler_InternalFunction)
    #forceref $oOOoCalc_COM_ErrorHandler
    If Not IsObj($oObj) Then Return SetError($_OOoCalcStatus_InvalidDataType, $0CALC_EXT_PARAM1, 0)
    If IsInt($vSheet) Then
        If $vSheet >= 0 And $vSheet <= $oObj.getSheets.count - 1 Then Return SetError($_OOoCalcStatus_Success, $0CALC_EXT_DEFAULT, True)
        Return SetError($_OOoCalcStatus_NoMatch, $0CALC_EXT_PARAM2, False)
    ElseIf IsString($vSheet) And $vSheet <> '' Then
        Local $asWorksheets = _OOoCalc_SheetList($oObj)
        For $iSheet = 1 To $asWorksheets[0]
            If $asWorksheets[$iSheet] == $vSheet Then Return SetError($_OOoCalcStatus_Success, $0CALC_EXT_DEFAULT, True)
        Next
        Return SetError($_OOoCalcStatus_NoMatch, $0CALC_EXT_PARAM2, False)
    EndIf
    Return SetError($_OOoCalcStatus_InvalidDataType, $0CALC_EXT_PARAM2, False)
EndFunc   ;==>__OOoCalc_WorksheetIsValid

 

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

all:

If Not IsObj($oObj) Then Return SetError($_OOoCalcStatus_GeneralError, 0, 0)

should be in most cases changed to:

If Not IsObj($oObj) Then Return SetError($_OOoCalcStatus_InvalidDataType, $0CALC_EXT_PARAM1, 0)

 

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

some refactoring:

Func __OOoCalc_CellRCToA1($iRow, $iCol)
    Local $iQuotient = Int($iCol / 26)
    Local $iRemainder = Mod($iCol, 26)
    Local $sChar = Chr(65 + $iRemainder)
    If $iQuotient <> 0 Then $sChar = Chr(65 + $iQuotient) & $sChar
    Return $sChar & String($iRow + 1)
EndFunc   ;==>__OOoCalc_CellRCToA1

 

WEnd
    If $bFlag Then Return SetError($_OOoCalcStatus_InvalidValue, 2, 0)
    
    $oObj.Sheets.insertNewByName($sSheet, $iPos)
    Return SetError($_OOoCalcStatus_Success, 0, 1)
EndFunc   ;==>_OOoCalc_SheetAddNew

 

 


in _OOoCalc_RowDelete and in _OOoCalc_RowInsert

You are using bad approach:

If $iRow < 0 Then $iRow = 0

it should be:

If $iRow < 0 Then Return SetError($_OOoCalcStatus_InvalidValue, 2, 0)

for example:

Func _OOoCalc_RowInsert($oObj, $iRow, $iNumRows = 1, $vSheet = -1)
    Local $oOOoCalc_COM_ErrorHandler = ObjEvent("AutoIt.Error", __OOoCalc_ComErrorHandler_InternalFunction)
    #forceref $oOOoCalc_COM_ErrorHandler
    If Not IsObj($oObj) Then Return SetError($_OOoCalcStatus_InvalidDataType, 1, 0)
    If Not IsInt($iRow) Then Return SetError($_OOoCalcStatus_InvalidDataType, 2, 0)
    If $iRow < 0 Then Return SetError($_OOoCalcStatus_InvalidValue, 2, 0)
    If Not IsInt($iNumRows) Then Return SetError($_OOoCalcStatus_InvalidDataType, 3, 0)
    If Not IsInt($vSheet) And Not IsString($vSheet) Then Return SetError($_OOoCalcStatus_InvalidDataType, 4, 0)
    If $vSheet > -1 And Not __OOoCalc_WorksheetIsValid($oObj, $vSheet) Then Return SetError($_OOoCalcStatus_NoMatch, 4, 0)
    Local $oSheet = __OOoCalc_GetSheet($oObj, $vSheet)
    If Not IsObj($oSheet) Then Return SetError($_OOoCalcStatus_GeneralError, 0, 0)
    $oSheet.getRows.insertByIndex($iRow, $iNumRows)
    Return SetError($_OOoCalcStatus_Success, 0, 1)
EndFunc   ;==>_OOoCalc_RowInsert

 

and the same approach with :

If $iCol < 0 Then $iCol = 0

 

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
14 hours ago, mLipok said:

I notice that this part:
 

; Don't understand why the sort is not working
For $iCounter = 2 To 6
    _OOoCalc_RangeSort($oCalc, "CALC", "B3:F6", $iCounter, True, True)
    MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, $sTitle, "B3:F6 Sorted by column " & Chr($iCounter + 64) & " (ascending)...")
Next

Currently works well :)

Tested on Apache OpenOffice 4.1.1

 

Right. Forgot to remove that comment. Fixed now.

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...