I'm fairly new to EB, and am self taught from the provided help files (6.5). I've written quite a few macros for many users but have run into a couple of issues.
1. I need my macro output to be into a Access table. (not via a linked .txt or .csv.
2. I need to be able to run multiple (sometimes multiples of the same macro) on multiple sessions.
3. In researching the above two issues, I see it may be easier to write these in VB(A)(#2 may not even be possible in EB), but even using calculus' FAQ I get several issues with my code (getfield is not defined for instance).
My question is this. Is number three a correct assumption? If so how different is the code. If not, I would still like to run the macro from Access, does anyone know how to do this? Below is some sample code:
sub main
'file objects
dim thisFile as string
dim nextnum as string
dim linefeed as string
'system objects
dim sys as object
dim sess as object
dim myscreen as object
'work objects
dim tollfree as string
dim logt as string
dim dnis as string
dim digits as string
dim reuse as string
dim row as integer
dim corp as string
dim lg1 as string
dim lg2 as string
dim lg3 as string
dim lg4 as string
dim lg5 as string
close
reset
set sys = createobject("extra.system")
if sys is nothing then
msgbox " session didnt work"
exit sub
end if
set sessionscollection = sys.sessions
set sess = sys.activesession
if sess is nothing then
msgbox " session didnt work"
exit sub
end if
set myscreen = sess.screen
filenumber = freefile
filenumber2 = freefile +1
filenumber3 = freefile +2
do
fileread = inputbox$ ("Enter filename to READ FROM (including PATH): ","Read From File Name","c:\Macro\trmie.txt")
if fileread = "" then
msgbox "You must enter a filename to read FROM"
else
filewrite = inputbox$ ("Enter filename to WRITE TO (including PATH): ","Write To File Name","c:\Macro\trmiout.txt")
if filewrite = "" then
msgbox "You must enter a filename to write TO"
end if
end if
loop until fileread <> "" and filewrite <> ""
tempfile = "c:\Macro\trimg.txt"
open fileread for input as #filenumber
open Filewrite for output as #filenumber2
open tempfile for output as #filenumber3
print #filenumber2, "Toll Free,LogTerm,DNIS,Digits,Re-Use"
'Process each number in the file
do
'Get a record
line input #filenumber,linefeed
tollfree = GetField (linefeed,1,",")
myscreen.sendkeys ("trmi<tab>e" & tollfree & " <enter>")
myscreen.waithostquiet (500)
corp = myscreen.getstring (3,8,8)
row = 11
do
if row = 21 then
myscreen.sendkeys ("<enter>")
myscreen.waithostquiet (500)
row = 11
end if
lg1 = myscreen.getstring (row,10,1)
if lg1 = " " then
lg1 = "0"
end if
lg2 = myscreen.getstring (row,11,1)
if lg2 = " " then
lg2 = "0"
end if
lg3 = myscreen.getstring (row,12,1)
if lg3 = " " then
lg3 = "0"
end if
lg4 = myscreen.getstring (row,13,1)
if lg4 = " " then
lg4 = "0"
end if
lg5 = myscreen.getstring (row,14,1)
if lg5 = " " then
lg5 = "0"
end if
logt = lg1 & lg2 & lg3 & lg4 & lg5
if logt = "00000" then
exit do
end if
print #filenumber3, tollfree & "," & corp & "," & logt
row = row + 1
loop
myscreen.sendkeys ("<PF10>")
myscreen.waithostquiet (1000)
close #filenumber3
open tempfile for input as #filenumber3
do
line input #filenumber3,linefeed
tollfree = getfield (linefeed,1,",")
corp = getfield (linefeed,2,",")
logt = getfield (linefeed,3,",")
myscreen.sendkeys ("trmi<tab>g" & corp & logt & "<enter>")
myscreen.waithostquiet (500)
dnis = myscreen.getstring (11,66,1)
digits = myscreen.getstring (12,66,10)
reuse = myscreen.getstring (13,66,2)
print #filenumber2, tollfree & "," & logt & "," & dnis & "," & digits & "," & reuse
loop until eof(filenumber3)
myscreen.waithostquiet(500)
close #filenumber3
open tempfile for output as #filenumber3
loop until eof(filenumber)
'Last Recored Processed
the_end:
close #filenumber
close #filenumber2
close #filenumber3
msgbox "File Complete"
end sub
Thanks
1. I need my macro output to be into a Access table. (not via a linked .txt or .csv.
2. I need to be able to run multiple (sometimes multiples of the same macro) on multiple sessions.
3. In researching the above two issues, I see it may be easier to write these in VB(A)(#2 may not even be possible in EB), but even using calculus' FAQ I get several issues with my code (getfield is not defined for instance).
My question is this. Is number three a correct assumption? If so how different is the code. If not, I would still like to run the macro from Access, does anyone know how to do this? Below is some sample code:
sub main
'file objects
dim thisFile as string
dim nextnum as string
dim linefeed as string
'system objects
dim sys as object
dim sess as object
dim myscreen as object
'work objects
dim tollfree as string
dim logt as string
dim dnis as string
dim digits as string
dim reuse as string
dim row as integer
dim corp as string
dim lg1 as string
dim lg2 as string
dim lg3 as string
dim lg4 as string
dim lg5 as string
close
reset
set sys = createobject("extra.system")
if sys is nothing then
msgbox " session didnt work"
exit sub
end if
set sessionscollection = sys.sessions
set sess = sys.activesession
if sess is nothing then
msgbox " session didnt work"
exit sub
end if
set myscreen = sess.screen
filenumber = freefile
filenumber2 = freefile +1
filenumber3 = freefile +2
do
fileread = inputbox$ ("Enter filename to READ FROM (including PATH): ","Read From File Name","c:\Macro\trmie.txt")
if fileread = "" then
msgbox "You must enter a filename to read FROM"
else
filewrite = inputbox$ ("Enter filename to WRITE TO (including PATH): ","Write To File Name","c:\Macro\trmiout.txt")
if filewrite = "" then
msgbox "You must enter a filename to write TO"
end if
end if
loop until fileread <> "" and filewrite <> ""
tempfile = "c:\Macro\trimg.txt"
open fileread for input as #filenumber
open Filewrite for output as #filenumber2
open tempfile for output as #filenumber3
print #filenumber2, "Toll Free,LogTerm,DNIS,Digits,Re-Use"
'Process each number in the file
do
'Get a record
line input #filenumber,linefeed
tollfree = GetField (linefeed,1,",")
myscreen.sendkeys ("trmi<tab>e" & tollfree & " <enter>")
myscreen.waithostquiet (500)
corp = myscreen.getstring (3,8,8)
row = 11
do
if row = 21 then
myscreen.sendkeys ("<enter>")
myscreen.waithostquiet (500)
row = 11
end if
lg1 = myscreen.getstring (row,10,1)
if lg1 = " " then
lg1 = "0"
end if
lg2 = myscreen.getstring (row,11,1)
if lg2 = " " then
lg2 = "0"
end if
lg3 = myscreen.getstring (row,12,1)
if lg3 = " " then
lg3 = "0"
end if
lg4 = myscreen.getstring (row,13,1)
if lg4 = " " then
lg4 = "0"
end if
lg5 = myscreen.getstring (row,14,1)
if lg5 = " " then
lg5 = "0"
end if
logt = lg1 & lg2 & lg3 & lg4 & lg5
if logt = "00000" then
exit do
end if
print #filenumber3, tollfree & "," & corp & "," & logt
row = row + 1
loop
myscreen.sendkeys ("<PF10>")
myscreen.waithostquiet (1000)
close #filenumber3
open tempfile for input as #filenumber3
do
line input #filenumber3,linefeed
tollfree = getfield (linefeed,1,",")
corp = getfield (linefeed,2,",")
logt = getfield (linefeed,3,",")
myscreen.sendkeys ("trmi<tab>g" & corp & logt & "<enter>")
myscreen.waithostquiet (500)
dnis = myscreen.getstring (11,66,1)
digits = myscreen.getstring (12,66,10)
reuse = myscreen.getstring (13,66,2)
print #filenumber2, tollfree & "," & logt & "," & dnis & "," & digits & "," & reuse
loop until eof(filenumber3)
myscreen.waithostquiet(500)
close #filenumber3
open tempfile for output as #filenumber3
loop until eof(filenumber)
'Last Recored Processed
the_end:
close #filenumber
close #filenumber2
close #filenumber3
msgbox "File Complete"
end sub
Thanks