Sign in to follow this  
Followers 0
Manjish

Excel error

3 posts in this topic

Hi,

Here's what I want my script to do:

1) An excel file will have entries. Depending on the status, these will be "OPEN" or "CLOSED".

2) My script will present user with a GUI having checkboxes of those items with status "OPEN"

3) User will selectitems which he wants to return.

4) After that he will be asked the date and person he's returning item to.

5) Depending on what he selected, the entries will be made for that item and status will be set to "CLOSED".

My script is already doing 1-4 without any problems. But when I add No.5 error occurs with _ExcelReadCell. I am not able to identify my mistake. Please help me. I have attached the folder, just copy to ur system, unzip it and run the .au3 file. Thanks and appreciate if any1 can identify whats going wrong.

Regards,

M


[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

1st) I made some changes in 1st While Loop. This stops the excel errors.

But i also think, you have to control your _excelwritecell calls as well. I think not all values are written correctly to your sheet.

2nd) I also had to declare some global variables beforehand to run your script properly. Also you worked with a hardcoded path to your excel sheet. You may work with macro @Scriptdir, e.g:

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

@2nd)

#include <GUIConstants.au3>
#include <excel.au3>
#Region ### START Koda GUI section ### Form=
$name5="a"
Global $sFilePath1 = @ScriptDir & "\Media_Management_System.xls"  
$oExcel = _ExcelBookOpen($sFilePath1)
$k=0
Global $indate, $RA, $n

@1st) While Loop:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ok
            gui12()
            $oExcel = _ExcelBookOpen($sFilePath1)   
            For $i=1 to $k
                If GUICtrlRead(eval("checkbox"&$i))=1 Then
                
                For $m=2 to 50000
                    $sCellValue = _ExcelReadCell($oExcel, $m, 5)
                    if $sCellValue="" then ExitLoop
                    MsgBox (0,"", "2. ExcelRead")
                    If _ExcelReadCell($oExcel, $m, 3)=$name5 and $sCellvalue=Eval("item"&$i) Then
                        MsgBox (4096,"",$indate & $RA)
                        _ExcelWriteCell($oExcel,$indate,$m,9)
                        _ExcelWriteCell($oExcel,$RA,$m,10)
                        _ExcelWriteCell($oExcel,"CLOSED",$n,11)
                    EndIf
                    
                Next
                
                EndIf
                _ExcelBookSave($oExcel)
            Next
            _ExcelBookClose($oExcel)
    EndSwitch
WEnd
Edited by 99ojo

Share this post


Link to post
Share on other sites

But i also think, you have to control your _excelwritecell calls as well. I think not all values are written correctly to your sheet.

To correctly make all entries to excel sheet, needed to change this line:

_ExcelWriteCell($oExcel,"CLOSED",$n,11)

to

_ExcelWriteCell($oExcel,"CLOSED",$m,11)

$n is an unused variable. I wanted to use it in a different way. Later scrapped that method. But forgot to remove $n.

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

Before posting, I had written it in this way only. Sorry to cause u the trouble. Dunno why it didn't get saved to the script.

All in all, these changes suggested by you work.. thanks a lot!!


[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

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