Jump to content

open/libre office help needed with cell write command


Recommended Posts

my code:

#include <OOoCalc.au3>

$file = @ScriptDir & "\slanje.ods"

If ProcessExists("soffice.exe") Then
;~  $oCalc = _OOoCalcBookAttach($file)
; _OOoCalcBookAttach doesnt work. i need to define here what $oCalc will be for _OOoCalcWriteCell to work
    WinWait("Calc")
    WinSetState("Calc", "", @SW_MAXIMIZE)
    WinActivate("Calc", "")

Else
    $oCalc = _OOoCalcBookOpen($file)
    WinWait("Calc")
    WinSetState("Calc", "", @SW_MAXIMIZE)
    WinActivate("Calc", "")

EndIf

_OOoCalcWriteCell($oCalc, "comething to write in cell","C25")

so calc write cell doesnt work if slanje.ods is already opened. it only works if the ELSE condition is met.

Link to comment
Share on other sites

You always have to open an ODS file using _OOoCalcBookOpen. It doesn't work by mixing hte OO UDF, GUI Automation and process checking.

Have a look at the Example Scripts forum and search for "OpenOffice Calc". You will find a lot of good examples there.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

the problem only happens when file is already open in openoffice

in that situation _OOoCalcWriteCell doesnt put values into cell

$oCalc is not defined good when i run the script while the file is open

i get this error when file is already open

C:Program FilesAutoIt3IncludeOOoCalc.au3 (302) : ==> The requested action with this object has failed.:
Local $oReturn = $oDesktop.loadComponentFromURL($sURL, "_default", 0, $aoProperties)
Local $oReturn = $oDesktop.loadComponentFromURL($sURL, "_default", 0, $aoProperties)^ ERROR

and this

: ==> Variable used without being declared.:
_OOoCalcWriteCell($oCalc, $nameart,"C23")
_OOoCalcWriteCell(^ ERROR

Edited by dickjones007
Link to comment
Share on other sites

You ALWAYS have to run _OOoCalcBookOpen to return the book object. Function _OOoCalcWriteCell relies on this object.

That's what I mean by "mixing OO UDF, GUI Automation and process checking". That's the wrong approach.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I'm not familiar with the OO UDF but the Excel UDF has a function to open a workbook and another to attach to an already open workbook.

With Excel I would try to attach to the workbook. If an error is returned then I would try to open the workbook.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

for OO there is _OOoCalcBookAttach, but it does not return good value for calc write to recognize it

also when i tried to put value of $oCalc to msgbox it returns empty.

do u know if there is any other/deeper :) way to check the value of $oCalc when the script opens book?

Link to comment
Share on other sites

:)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 4 years later...

Hello,

I tried the the script with a .ods file created with Libreoffice 6.0.2 which works on Windows 7 64bit. But I didn't have success.

I tried this code:

$oCalc = _OOoCalc_BookOpen("Results.ods")
WinWait("Results.ods")
WinSetState("Results.ods", "", @SW_MAXIMIZE)
WinActivate("Results.ods", "")
_OOoCalc_WriteCell($oCalc, "something to write in cell", 1, 1)
_OOoCalc_CellSetColors($oCalc, 0x0000FF, 0x00FF00, 0, 0) ;Foreground and Background color in 0xRRGGBB
_OOoCalc_WriteCell($oCalc, "'===================", "C3") ;...or with direct address

but nothing happen.

My suspicion is that could be from some incompatibilities with the last Libreoffice version 6.0.2.

Someone else tries the script with 6.0.2 Libreoffice version?

Another problem could be because Libreoffice is not installed; I worked with it as portable tool. Even this, .ods file type is set to be opened default with portable Libreoffice 6.0.2

 

Many thanks for your help!

 

Link to comment
Share on other sites

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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