Jump to content

Recommended Posts

Posted

Perplexed by why the $sCellValue variable is failing to store any data. I tried numbers and text. I double checked my test.xls file to make sure it had data. Is Excel security blocking the script for getting in? I am using msgbox for debugging purposes. I would delete it in the scripts final version. Thanks for any help.

;
;##################################
; Include
;##################################
#Include<file.au3>
#include <Excel.au3>
#include <Array.au3>
;##################################
; Variables
;##################################


$sFilePath1 = @ScriptDir & "c:\test.xls" ;This file should already exist
$oExcel = _ExcelBookOpen($sFilePath1)
_ExcelWriteCell($oExcel, "I Wrote to This Cell", 1, 1) ;Write to the Cell
$sCellValue = _ExcelReadCell($oExcel, 1, 1)

MsgBox(0, "", "The Cell Value is: " & @CRLF & $sCellValue, 2)
Posted (edited)

$sFilePath1 "c:\test.xls"

@ScriptDir = Directory containing the running script. (Result does not contain a trailing backslash) I don't know, I will guess that this is where my script or my AutoIt.exe is located. I don't even know if @ScriptDir is a variable.

I am certain $sCellValue is a variable. And this variable should have a value, if not something is wrong such as its not declared, its data needs to be set to zero before using it in the script or sumtin.

Edited by meatsack
Posted (edited)

@scriptdir is the current directory your script is in. So if the path is wrong your file never gets open and no data gets put into $sCellValue. filepath needs to be:

$sFilePath1 = @ScriptDir & "\test.xls"
Edited by Beege
Posted

I wonder why I'm still helping you ...

Whoops my bad. Works perfectly now.

@scriptdir is the current directory your script is in. So if the path is wrong your file never gets open and no data gets put into $sCellValue. filepath needs to be:

$sFilePath1 = @ScriptDir & "\test.xls"

Thank you. I should have msgboxed the @ScriptDir variable. I didn't even know it was a variable. I'll try msgbox everything before I use the forum.

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