Sign in to follow this  
Followers 0
dickjones007

open/libre office help needed with cell write command

9 posts in this topic

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.

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

ok i understand

i know it relies on it

do you maybe have any solution for me on how to write to cells to already open book?

i searched everv post related to openoffice and found no such thing

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

omg i found the error

i was using $file for calc attach which equals full path of the file

i should have used $ime which is only the name of the file

BIG LOL and a relief

Edited by dickjones007

Share this post


Link to post
Share on other sites

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


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
Sign in to follow this  
Followers 0