xuzo

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

6 posts in this topic

#1 ·  Posted

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



#2 ·  Posted

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

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

#4 ·  Posted

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

#5 ·  Posted

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

#6 ·  Posted

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