I'm getting an overflow error from a CVDate function. I have no idea what's causing it ... when I write a test program using input boxes instead of getstring, etc it works fine. I'm sure that there is something I did earlier in the listing that's messing it up somehow, but i really can't say what it is.
And oh, it's not just the constructed string variable causing the overflow error; swapping around the dat1= and dat2= lines just causes it to crash at the first use.
Thank you.
And oh, it's not just the constructed string variable causing the overflow error; swapping around the dat1= and dat2= lines just causes it to crash at the first use.
Thank you.
Code:
Sub Main
dim sys as Object, sess as Object, xl as Object, wb as Object, nwb as object
dim notes1() as string, notes2() as string
dim icount as integer, jcount as integer, xlcount as integer, kcount as integer
dim notetype as string, quit as integer, notedat as string
dim acct as string, age as integer
dim dat1 as integer, dat2 as integer
dim aday as string, amonth as string, ayear as string, newmonth as string
'GET ACCESS TO THE TOP LEVEL E!PC OBJECT...
set sys = CreateObject("Extra.System")
if sys is nothing then
msgbox("Could not create Extra.System...is E!PC installed on this machine?")
exit sub
end if
'GET ACCESS TO THE CURRENTLY ACTIVE SESSION...
set sess = sys.ActiveSession
if sess is nothing then
msgbox("No session available...stopping macro playback.")
exit sub
end if
'MAKE SURE THE ACC SCREEN IS ACTIVE
cond=sess.Screen.GetString(1,45,3)
if cond <> "ACC" then
msgbox("Please manuever to ACC screen and try again")
exit sub
end if
set xl = CreateObject("Excel.Application")
if xl is nothing then
msgbox("Could not create Excel.Application...is Excel installed on this machine?")
exit sub
end if
sFile = xl.getopenfilename
set wb = xl.Workbooks.Open(sFile)
redim notes1(1)
redim notes2(1)
notes1(1)="ACCT"
notes2(1)="NOTES"
xlcount=1
icount=2
Do
if wb.worksheets("sheet1").cells(icount,1)="" then
exit Do
end if
acct=wb.worksheets("sheet1").cells(icount,1)
if left(acct,1)<>"0" then
acct="0"&acct
end if
sess.screen.moveto 4,11
sess.screen.waitforcursor 4,11
sess.screen.sendkeys(acct)
sess.screen.sendkeys("<enter>")
sess.screen.waithostquiet(0)
quit=0
'DETERMINE IF NOTES ARE PERMAMENT OR GENERAL, THEN SEARCH DOWN FOR GENERAL NOTES LESS THAN SEVEN DAYS OLD
'''''''''ADD CHECK FOR ALL P TYPE NOTES ON A SCREEN AND RELOOP
for jcount=7 to 41
notetype=sess.screen.getstring(jcount,2,1)
Select Case notetype
case "P"
case "G"
aday=trim(sess.screen.getstring(jcount,4,2))
amonth=trim(sess.screen.getstring(jcount,7,3))
ayear=trim(sess.screen.getstring(jcount,11,2))
select case amonth
case "JAN"
newmonth="01"
case "FEB"
newmonth="02"
case "MAR"
newmonth="03"
case "APR"
newmonth="04"
case "MAY"
newmonth="05"
case "JUN"
newmonth="06"
case "JUL"
newmonth="07"
case "AUG"
newmonth="08"
case "SEP"
newmonth="09"
case "OCT"
newmonth="10"
case "NOV"
newmonth="11"
case "DEC"
newmonth="12"
end select
notedat = newmonth & "/" & aday & "/" & ayear
dat1 = CVDate(notedat)
dat2 = CVDate(date)
age = dat2 - dat1
if abs(age) > 7 then
quit=1
else
xlcount=xlcount + 1
redim preserve notes1(xlcount)
redim preserve notes2(xlcount)
notes1(xlcount)=acct
notes2(xlcount)=sess.screen.getstring(jcount,19,62)
end if
case else
quit=1
end select
if quit=1 then
exit for
end if
next jcount
icount=icount+1
Loop
set nwb = xl.Workbooks.Add
for icount=1 to xlcount
nwb.worksheets("sheet1").cells(icount,1)=notes1(icount)
nwb.worksheets("sheet1").cells(icount,2)=notes2(icount)
next icount
xl.visible = true
End Sub
[end code]