Jump to content
xuzo

Can't open XLS files with open office calc in examples

Recommended Posts

xuzo

Trying to run an example file but I don't have MS Office, only open office calc.

What code should I substitute in there so this script runs with open office?

#include <MsgBoxConstants.au3>

; COM Test file
;
; Excel Automation Example
;

Local $oMyExcel = ObjCreate("Excel.Application") ; Create an Excel Object

If @error Then
    MsgBox($MB_SYSTEMMODAL, "ExcelTest", "Error creating the Excel Object. Error code: " & @error)
    Exit
EndIf

If Not IsObj($oMyExcel) Then
    MsgBox($MB_SYSTEMMODAL, "ExcelTest", "I'm sorry, but creation of the Excel object failed.")
    Exit
EndIf

$oMyExcel.Visible = 1 ; Let the guy show himself

$oMyExcel.workbooks.add ; Add a new workbook

; Example: Fill some cells

MsgBox($MB_SYSTEMMODAL, "", "Click 'ok' to fill some cells")

Local $i
Local $j

With $oMyExcel.activesheet
    For $i = 1 To 15
        For $j = 1 To 15
            .cells($i, $j).value = $i
        Next
    Next

    MsgBox($MB_SYSTEMMODAL, "", "Click 'ok' to clear the cells")
    .range("A1:O15").clear

EndWith

Sleep(2000)

$oMyExcel.activeworkbook.saved = 1 ; To prevent 'yes/no' questions from Excel

$oMyExcel.quit ; Get rid of him.

MsgBox($MB_SYSTEMMODAL, "ExcelTest", "Is Excel gone now ?")
; Nope, only invisible,
; but should be still in memory.

$oMyExcel = "" ; Only now Excel is removed from memory.

Exit

 

Share this post


Link to post
Share on other sites
water

You can't compare Excel and oOCalc.
Best is to rewrite your script using the OpenOffice UDF as described here: https://www.autoitscript.com/wiki/User_Defined_Functions#OpenOffice.2FLibreOffice


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Skysnake

I generate CSVs which OpenOffice opens effortlessly. :)

 


Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites
xuzo

I want to use all the example files , they are all excel...

Isn't there a  quick find and replace I can do in the example files so they work with open calc?

Share this post


Link to post
Share on other sites
water

No. Excel and oO do not work the same way. So a simple f&r isn't possible.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
xuzo

Ok thank you, [solved]

 

 

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

×