Sign in to follow this  
Followers 0
Paul2

ExcelReadCell always 0

5 posts in this topic

#1 ·  Posted (edited)

Hello everybody,

I just started using Autoit and this is my first program I actually want to put to use. It opens an Excel file  were it should copy values to a warehouse management system. But the values are always 0.

Does anybody know why? I try to get the data from range "A19"  and can´t figure out why I won´t get it. 

#include <Excel.au3>

Func _WinWaitActivate($title, $text, $timeout = 0)
    WinWait($title, $text, $timeout)
    If Not WinActive($title, $text) Then WinActivate($title, $text)
    WinWaitActive($title, $text, $timeout)
EndFunc   ;==>_WinWaitActivate

$Lieferschein = FileOpenDialog("Lieferschein auswählen", "C:\Users\Paul\Dropbox\JTL\Lieferscheine", "(*.*)") ;Opens the packinglistfolder
_ExcelBookOpen($Lieferschein) ;Opens the choosen Packinglist

$Zeile = 18 ;Variable for Cell (Cell 18 ist the header of the packagelist)
$Anzahl = 1

_WinWaitActivate("Manuelle Bestellung beim Lieferanten", "Status der Bestellun") ;The window I want the data to copy to
MouseClick("left", 659, 938, 1) ;Activates the right box

If _ExcelReadCell($Lieferschein, $Zeile, 1) = "SAP-Artikel-Nr." Then ;Checks if the xlsx is in right form
    Do
        $Zeile = $Zeile + 1
        $SAP = _ExcelReadCell($Lieferschein, $Zeile, 1) ;Saves SAP Number
        $Menge = _ExcelReadCell($Lieferschein, $Zeile, 4) ;Saves quantity 
        $Zeile = $Zeile + 1 ;Counts
        MsgBox(0, $SAP, $Menge) ;Check Values


        For $Zaehler = $Menge To 0 Step -1 ;Puts article in jtl as often as its on the packinglist
            Send($SAP)
            Send("{Enter}")
        Next

    Until $SAP = "" ;Ends when all are in

Else
    MsgBox(0, "Fehler", "Der Lieferschein hat nicht die Gültige Form")

EndIf

The Spreadsheet: (From Row 18 to 22)

       A                                     B                                     C(empty)                                     D                                   

18  SAP-Artikel-Nr.  Artikel-Bezeichnung                                                                          Menge

19  100015016       AEG POCKET SPANNUNGSWANDLER SI 150 150W IPOD              1 

20  100020938       CARTREND OBD II DIAGNOSEGERÄT                                             1 

21  100015656       BRÜDER MANNESMANN HANDWERKER - KARTUSCHENPISTOLE 2 

22  100020278       BRÜDER MANNESMANN M10997 ZANGENSATZ 4-TLG.                 1

Thanks a lot for your help!

Best regards,

Paul

Edited by Paul2

Share this post


Link to post
Share on other sites



Thanks a lot! Now it works.

Share this post


Link to post
Share on other sites

Paul2,

if performance is an issue you could try my rewrite of the Excel UDF.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks! Right now the Data is not to big so im okay with the performance. I will come back to this if the data gets bigger.

Best regards

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