Sign in to follow this  
Followers 0
ranhalt

Create new Excel spreadsheet

6 posts in this topic

I'm going through the forums and examples, but can't find anything that just creates a brand new Excel spreadsheet and saves it to a target dir/filename for me to play with later.

example, I want the script to create test.xls in the working directory. thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

brokendownforyou:

type "excel" in the help search, you'll see it almost immediately ;)

Edited by gcue

Share this post


Link to post
Share on other sites

#include <Excel.au3>

$oExcel = _ExcelBookNew()

_ExcelBookSave($oExcel) ;Save File With No Alerts
If Not @error Then MsgBox(0, "Success", "File was Saved!", 3)

By default, this creates in My Documents as Book1.xls. How do I specify location and name?

Share this post


Link to post
Share on other sites

The instructions for SaveAs weren't clear enough that the second parameter includes the filename, it seems like just the path.

#include <Excel.au3>

$oExcel = _ExcelBookNew()

_ExcelBookSaveAs($oExcel, @DesktopDir & "\Checklist","xls")

Share this post


Link to post
Share on other sites

What about opening an existing spreadsheet? I created a blank xls and try to open it using

$excel = _ExcelBookOpen("test.xls")

but get the error

C:\Program Files\AutoIt3\Include\Excel.au3 (189) : ==> The requested action with this object has failed.:

If $sPassword = "" And $sWritePassword = "" Then .WorkBooks.Open($sFilePath, Default, $fReadOnly)

If $sPassword = "" And $sWritePassword = "" Then .WorkBooks.Open($sFilePath, Default, $fReadOnly)^ ERROR

>Exit code: 1 Time: 3.745

What's the cause?

Share this post


Link to post
Share on other sites

I was having some trouble with saving as in Excel too - the closest I could come was saving into a folder on my c: drive:

#include <Excel.au3>

$oExcel.saveas("c:\testfolder\test.xls")

where $oExcel is the workbook object.

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