Jump to content

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


Recommended Posts

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

 

Link to post
Share on other sites

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 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version 1.6.5.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 (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

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 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version 1.6.5.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 (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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.

×
×
  • Create New...