Jump to content
Sign in to follow this  

Local or Global

Recommended Posts



can any body tell me why I cant save a file with these settings:

#include <Excel.au3>
#include <Date.au3>
#include <DateTimeConstants.au3>
Local $iBatch = String(@MDAY & @MON & @YEAR & @YDAY)

$sFilePath1 = @ScriptDir & "\Test1.xls" ;This file should already exist
$oExcel = _ExcelBookOpen($sFilePath1)

If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
ElseIf @error = 2 Then
    MsgBox(0, "Error!", "File does not exist - Shame on you!")

_ExcelBookSaveAs($oExcel, @DesktopDir & $iBatch, "xls")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iBatch = ' & $iBatch & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
If Not @error Then MsgBox(0, "Success", "File was Saved!", 3)
_ExcelBookClose($oExcel, 1, 0) ;This method will save then Close the file, without any of the normal prompts, regardless of changes

The script announces success w/out error...but no file is saved.

Share this post

Link to post
Share on other sites

Dont know how exel works but try this

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


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

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.