Jump to content

Recommended Posts

Posted (edited)

can you guys tell what's wrong? It keeps running till I hit ctrl+break

#include <Excel.au3>
 
;wrote by rafael cadina, 03/04/2014 00:00
 
$Path="C:\Users\rafael.cadina\Desktop\jjj\Detailing Plan\2602 0859 Detailing Plan.xls" ;Set Full Path to Detailing Plan Excel File
$ExcelWB=_ExcelBookAttach($Path) ;Do not change
$ExcelWS="Vaccines_12 - PED" ;Select Worksheet from Detailing Plan Excel File
$NYear=8 ;Number of years analyzed +1
 
$StratosWindow=("Stratos") ;Set Stratos Window Name
$FirstRow=6 ;First Row Index Containing a Product
$FirstColumn=2 ;First Column Index Containing a Product
$YearRow=4 ;First Row Index Containing a Year
$YearColumn=1 ;First Column Index Containing a Year
$ComboBoxIndex=10 ;Do not change
$WeightIndex=13 ;Do not change
Global $YearRowArray[$NYear] ;years array
 
_ExcelSheetActivate($ExcelWB,$ExcelWS)
 
$YearRowArray[1]=$YearRow
$YearCell=_ExcelReadCell($ExcelWB,$YearRow,$YearColumn)
 
;Set Rows For Each Year in Array
For $k=2 To $NYear
 
Do
$YearRow=$YearRow+1
$YearCell=_ExcelReadCell($ExcelWB,$YearRow,$YearColumn)
Until $YearCell<>""
 
$YearRowArray[$k]=$YearRow
 
Next
 
$i=$FirstRow
$j=$FirstColumn
 
$CellValue=_ExcelReadCell($ExcelWB,$i,$j)
 
For $l=2 To $NYear
 
While $CellValue<>""
 
While $CellValue<>""
ControlCommand($StratosWindow,"","TComboBox"&$ComboBoxIndex,"SelectString",$CellValue)
ControlSetText($StratosWindow,"","TSmEdit"&$WeightIndex,_ExcelReadCell($ExcelWB,$i,$j+1)*100)
$i=$i+1
$CellValue=_ExcelReadCell($ExcelWB,$i,$j)
$ComboBoxIndex=$ComboBoxIndex-1
$WeightIndex=$WeightIndex-1
WEnd
 
$i=$FirstRow
$j=$j+2
$CellValue=_ExcelReadCell($ExcelWB,$i,$j)
$ComboBoxIndex=10
$WeightIndex=13
ControlClick($StratosWindow,"",67984)
 
WEnd
$j=$FirstColumn
$i=($YearRowArray[$l]+2)
$CellValue=_ExcelReadCell($ExcelWB,$i,$j)
Next
Edited by Melba23
Added tags
Posted

hello rafaelcadina,

to troubleshoot multiple loops script, you need first to find which one of your loops does not end.

on every loop in turn, put an indicator that will let you debug the stop condition. for example, like this:

Do
    $YearRow=$YearRow+1
    $YearCell=_ExcelReadCell($ExcelWB,$YearRow,$YearColumn)
    MsgBox(0,'$YearCell',$YearCell) ; add this line
Until $YearCell<>""

so you can follow "live" on the progress of the loop.

note: when you post code to the forum, please use the correct tagging (or use the dedicated button in the toolbar, the one that is tagged "Code").

Signature - my forum contributions:

  Reveal hidden contents

 

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