VoiceGuide IVR Software Main Page
Jump to content

Vb Script Issue Reading An Excel File

Recommended Posts

I get a type mismatch error line 17 character 1. Can someone help. I don't understand much about VB script. I want the IVR to remember, from the prior call, What line, of 2, the call was transfered to and then send the new call to the other line. I have no luck with the Eval funtions, it seams that $RV's become empty at the end of a call. I am now trying to set up a VB that changes an excel field, Cell (1,1), form a 1 to a 2 and then from a 2 to a 1 based on the prior call.

 

Am I making this too difficult ?? is their an easier way?

 

 

Dim xlApp 'Excel.Application

Dim xlBook 'Excel.Workbook

dim xlSht

Dim filename, value1, sReturnedRVs

 

 

filename = "c:\Agcy WAVS\Upagent.xls"

 

Set xlApp = CreateObject("Excel.Application")

set xlBook = xlApp.WorkBooks.Open(filename)

set xlSht = xlApp.activesheet

 

value1 = Abs(Cint(xlSht.Cells(1, 1).Value))

 

sReturnedRVs = "[value1]{" & value1 & "}"

 

iRet = WriteResultFile(sReturnedRVs)

 

workbook.close False

excel.quit

Share this post


Link to post

The script uses the "WriteResultFile" function - but that function itself has not been included:

function WriteResultFile(strResult)

const ForReading=1, ForWriting=2, ForAppending=8

Dim filename, fso, ts, outdata, outdata2, outdata3

 

filename = "VGRUNRESULT_$RV_DEVICEID.TXT"

set fso = CreateObject("Scripting.FileSystemObject")

set ts = fso.OpenTextFile(filename, ForWriting, True)

ts.WriteLine(strResult)

ts.Close

WriteResultFile = 0

end function

there were a few problems furhter down as well... try using this:

Dim xlApp 'Excel.Application

Dim xlBook 'Excel.Workbook

dim xlSht

Dim filename, value1, sReturnedRVs

 

filename = "c:\Agcy WAVS\Upagent2.xls"

 

Set xlApp = CreateObject("Excel.Application")

set xlBook = xlApp.WorkBooks.Open(filename)

set xlSht = xlApp.activesheet

 

value1 = Abs(Cint(xlSht.Cells(1, 1).Value))

sReturnedRVs = "[value1]{" & value1 & "}"

iRet = WriteResultFile(sReturnedRVs)

xlBook.close False

xlApp.quit

 

 

function WriteResultFile(strResult)

const ForReading=1, ForWriting=2, ForAppending=8

Dim filename, fso, ts, outdata, outdata2, outdata3

 

filename = "VGRUNRESULT_$RV_DEVICEID.TXT"

set fso = CreateObject("Scripting.FileSystemObject")

set ts = fso.OpenTextFile(filename, ForWriting, True)

ts.WriteLine(strResult)

ts.Close

WriteResultFile = 0

end function

 

Result Variables are only valid during the current call - but if you want to schedule a new call from within the current call you can pass the Result Variables as parameters - see the "Variables" text box of the "Send Phone Message" module...

Share this post


Link to post

Current versions of VoiceGuide no longer need to "Write a Result File" - they can just return info back to VG using one of the COM functions. See:

 

http://www.voiceguide.com/vghelp/html/com_...esultReturn.htm

http://www.voiceguide.com/vghelp/html/com_...Script_Goto.htm

http://www.voiceguide.com/vghelp/html/com_...cript_Gosub.htm

etc.

 

Some more VBScript samples are also at: http://www.voiceguide.com/vghelp/html/modVbs.htm

Share this post


Link to post

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
×