Sign in to follow this  
Followers 0
Klexen

Trying to use 2 loops I think...

1 post in this topic

#1 ·  Posted (edited)

Okay, what I'm trying to do is have each sheet in the array go through the do loop. Each sheet prompting user for where the last instance of a name is listed so it can stop, and move on to next sheet.

#include <Excel.au3>
#include <Word.au3>
#include <array.au3>

$sFilePath1 = "S:\IT\Jason\excel.xls" ;This file should already exist
$oExcel = _ExcelBookOpen($sFilePath1)

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

Local $avArray[6]

;Excel sheets

$avArray[0] = "AAC-OVER$50 TO ESCH"
$avArray[1] = "AIB-OVER $50 TO ESCH"
$avArray[2] = "BEDFORD"
$avArray[3] = "CRUSADER-STALE 100.140"
$avArray[4] = "CRUSADER-OVER $50 TO ESCH"
$avArray[5] = "UNIFAX-OVER $50 TO ESCH"


_ExcelSheetActivate($oExcel, $avArray)

$CertType = InputBox("","Please enter Certification format")

$RowNumber = InputBox("","What row number the last name is listed on?")


$i = 8
Do 

$aArray1 = _ExcelReadArray($oExcel, $i, 2, 9, 0, 0)

$aDate = $aArray1[6]

$year = StringMid ($aDate, 1, 4)
$mon = StringMid ($aDate, 5, 2)
$day = StringMid ($aDate, 7, 2)

$aArray1[6] = ($mon & "/" & $day & "/" & $year)
$aArray1[8] = "$"&$aArray1[8]

$oWordApp = _WordCreate ("")
$oDoc2 = _WordDocOpen ($oWordApp, "S:\IT\Jason\word.doc")
$oDoc = _WordDocGetCollection($oWordApp, 0)
$oFind = _WordDocFindReplace($oDoc, "DATEHERE", "May 12, 2009")
$oFind = _WordDocFindReplace($oDoc, "NAME1", $aArray1[0])
$oFind = _WordDocFindReplace($oDoc, "ADDRESS1", $aArray1[1])
$oFind = _WordDocFindReplace($oDoc, "CITY1", $aArray1[2])
$oFind = _WordDocFindReplace($oDoc, "STATE1", $aArray1[3])
$oFind = _WordDocFindReplace($oDoc, "ZIPCODE1", $aArray1[4])

$oFind = _WordDocFindReplace($oDoc, "CHECKNUMBER", $aArray1[5])
$oFind = _WordDocFindReplace($oDoc, "CHECKDATE", $aArray1[6])
$oFind = _WordDocFindReplace($oDoc, "CERT", $CertType&":"&" "&$aArray1[7])
$oFind = _WordDocFindReplace($oDoc, "AMOUNTHERE", $aArray1[8])

;Print
sleep(1000)
Send("^p")
sleep(500)
send("{ENTER}")
sleep(200)

_wordquit($oWordApp,0)

$i = $i + 1

until $i = $RowNumber

EDIT: Ok nm! I figured it out!

Edited by Klexen

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