Jump to content

Create new Excel spreadsheet


ranhalt
 Share

Recommended Posts

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

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

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

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...