Contents

VoiceGuide Help
1. Introduction
Welcome To VoiceGuide
Which version to use
2. System Configuration
System Requirements
Installing v7.x - Dialogic
Installing v7.x - VoIP / HMP
Installing v6.x - Dialogic
Installing v5.x - Voice Modems
Installing v5.x - CAPI compatible cards
Installing v5.x - Dialogic
Installing v5.x - Dialogic Wave Drivers
Text To Speech
Call Transfers and Conferencing
ODBC Data Sources
End of Call Detection
Distinctive Ring Detection
T1/E1 ISDN Configuration
T1/E1 RobbedBit/CAS/R2 Configuration
VoIP Line Registration
Command Line Options
Registering VoiceGuide
Unique System Identifier
3. Script Design
Introduction
Graphical Design Environment
Module Types
Paths
Result Variables
Call Start
Call Finish
Multilanguage Systems
Protected Scripts
Sound files
Testing Scripts
4. Modules Reference
Play
Record
Get Numbers
Say Numbers
Transfer Call
Send Phone Message
Send Pager Message
Send Email
Database Query
Run Program
Time Switch
Evaluate Expression
Run VB Script
Send DDE Command
Hangup Call
5. Voicemail
Introduction
Voicemail System Manager
Voicemail Menus
Message Lamps
6. Outbound Dialing
Loading Numbers to Call
Detect Call Answer
Predictive Dialers
External OutDialQue Source (v7)
External OutDialQue Source (v6)
7. Speech Recognition
Introduction
Grammars
Install LumenVox
8. Logs
Script Logs
Call Detail Records (CDRs)
9. ActiveX / COM Interface
Admin_TraceLogAdd
Dialer_MakeCall
Dialer_OutDialQueAdd
Bridge_Connect
Bridge_Disconnect
Line_Hangup
Line_Pickup
Play_Start
Play_Stop
Record_Stop
Record_Start
Record_2Lines_Start
Run_ResultReturn
RvGet
RvGet_All
RvGet_AllXml
RvSet
RvSet_RvList
Script_Gosub
Script_Goto
Script_Return
Serial_Tx
Vm_Event
Vm_VmbConfig_Get
Vm_VmbConfig_Set
10. PBX Integration (CTI)
Inband Signaling
Ericsson MD110 Voicemail Interface
Legal Information
Copyright & Disclaimer

 
Home
VoiceGuide Online Help
Prev Page Next Page
 
 

Run VBScript

This module will run a VBScript. Result Variables can be used throughout the VBScript. 

After starting the VBScript VoiceGuide can:

Continue, without waiting for VBScript to complete.
Wait until VBScript completes.
Wait until VBScript and sound file completes.

 

Continue, without waiting for VBScript to complete option

VoiceGuide will immediately continue down the "Success" path once VBScript was started successfully. If VBScript could not be started successfully then the "Fail' path is taken. If the path that VoiceGuide should be following is not defined then VoiceGuide will hang up the call.

 

Wait until VBScript completes option

VoiceGuide will wait until the VBScript finishes running, or a response from the executing VBScript is received.

VBScript can send responses back to VoiceGuide while it is executing by calling one VoiceGuide's ActiveX/COM functions. The functions which are considered to return a result back to VoiceGuide are: Run_ResultReturn(), Script_Gosub(), Script_Goto(), Script_Return(). For more information on VoiceGuide's ActiveX/COM interface please see the COM Interface section of Help file.

Once VoiceGuide detects that a VBScript has completed and no COM response was received beforehand then VoiceGuide will see if a "Result File" has been created by the script. If one has been created then VoiceGuide will read in it's contents and then determine what to do next based on the contents of the file.

The syntax of the Result File is the same as that used by the Run Program module. Please refer to the Run Program module Help file's section for more information.

A "Success" or Result Variable list must be returned to VoiceGuide (either though a Run_ResultReturn COM function or a Result File) in order for it to go down the Success path.
If no result is returned then the "Fail" path is taken after the VBScript completes.
Calls to Script_Gosub(), Script_Goto() and Script_Return() functions result in immediate running of the next module.

Any sound files still playing when VBScript completes will be stopped.

 

Wait until VBScript and sound file completes option

VoiceGuide will wait until the VBScript finishes running (or a response from the executing VBScript is received) and until the sound file playing completes. Sound file to play can be specified either using the "sound file to play" text box or can be started from with the VBScript itself using the Play_Start COM function.

Other functionality is similar to the "Wait until VBScript completes" option above.

 

Limiting maximum execution time

To limit the length of time the script is allowed to run for to run, a Timeout Path should be defined. If the script does not finish before the timeout occurs the script will be terminated and the timeout path will be taken. The timeout value is in seconds and should not be set to 0 - a value of 0 will result in the script being aborted immediately after it is started, without giving it any chance to run. Minimum timeout value used should be 2 seconds.

 

Play Tab

If "Wait Until VBScript Finishes" option is selected, the sound file specified in the Play tab will be played while the started program is executing. The playing of the sound file will be stopped as soon as the the program finishes.

 

Writing VBScripts

For more information and reference on VBScripting please go to msdn.microsoft.com/scripting and see the "VBScript Documentation" option.

A pretty good book on VBScript is:
"VBScript in a Nutshell" by Matt Childs, Paul Lomax & Ron Petrusha
ISBN: 1-56592-720-6

VBScript editors which you can use to develop your scripts before moving them over the the Run VBScript module can be found at: http://www.adersoft.com/vbsedit and www.vbsedit.com. You may also want to read here.

Following are some examples of VBScripts which can be ran in the Run VBScript module. Extensive use of VBScripting is also made by the VoiceGuide's Voicemail system. See VoiceGuide's \system\vm\ directory.

 

Using Result Variables in VBScripts

Before running the VBScript VoiceGuide will first see if there are any Result Variables specified within the script, and if there are then VoiceGuide will first replace them with their current values and run the resulting script then.

If the Result Variable is not defined then VoiceGuide will replace it with an empty string. For this reason it is often desirable to have the Result Variables used with quotes specified around them.

Eg: If Caller ID information did not arrive then VoiceGuide will replace $RV_CIDNUMBER  with an empty string before letting the VBScript run.

So, if Caller ID information did not arrive this code:

If $RV_CIDNUMBER = "" Then
   CallerID = "Unknown"
Else
   CallerID = $RV_CIDNUMBER
End if

would be changed to

If = "" Then
   CallerID = "Unknown"
Else
   CallerID =
End if

Which you can see is not valid VBScript and hence and error will occur.

But if you write the code using quotes around the RVs, like this:

If "$RV_CIDNUMBER" = ""
   Then CallerID = "Unknown"
Else
   CallerID = "$RV_CIDNUMBER"
End if

and Caller ID information did not arrive then the resulting VBScript which VoiceGuide actually runs would be:

If "" = "" Then
   CallerID = "Unknown"
Else
   CallerID = ""
End if

Which is a valid VBScript and when running it no errors will be generated and the script will work as expected.

Result Varaiables should not be directly used in places where replacement with a blank would cause a syntax error. Instead a variable which gets set to the RV value beforehand should be used in those situations. That way there is no syntax error and the check for whether RV holds any data can be made earlier in the script and the appropriate action taken if RV does not hold a value.

Another alternative is to have Evaluate Expression modules before the Run VBScript module checking to see if some data is assigned to the RVs used in the VBScript. That way the VBScript would not even be ran if RVs of interest have not data assigned to them.

 

Example : Save information to a file

The VBScript below will append a line of text to the file C:\LogCall.txt - the line of text will contain information about start of the call, caller's telephone number and information entered by caller in module "EnterClientNumber". Result Variables are used in this script to allow information from VoiceGuide to be visible to the VBScript.

Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
set fso = CreateObject("Scripting.FileSystemObject")
set tsFile = fso.OpenTextFile("C:\LogCalls.txt", ForAppending, True)
tsFile.WriteLine "
$RV_STARTTIME, $RV_CIDNUMBER, $RV[EnterClientNumber]"
tsFile.Close
set tsFile = Nothing
set fso = Nothing

Alternatively, if many different processes may be using the file at the same time you may want to ensure that your script will try repeatedly to write to the log file if necessary:

Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
set fso = CreateObject("Scripting.FileSystemObject")
on error resume next
set tsFile = fso.OpenTextFile("C:\LogCalls.txt", ForAppending, True)
while err.number <> 0
  Wscript.sleep 100 'pause here for a while before trying to open the file again.
  err.clear

  set tsFile = fso.OpenTextFile("C:\LogCalls.txt", ForAppending, True)
wend
tsFile.WriteLine "
$RV_STARTTIME, $RV_CIDNUMBER
, $RV[EnterClientNumber]"
tsFile.Close
set tsFile = Nothing
set fso = Nothing
 
Example : Read information from a file

The VBScript below will read the contents of file C:\CurrentPrices.txt and will assign them to VoiceGuide Result Variable $RV[ReadInPrice].

set fso = CreateObject("Scripting.FileSystemObject")
set fileUnitPrice = fso.OpenTextFile("C:\CurrentPrice.txt")
sEntireFile = fileUnitPrice.ReadAll
set fileUnitPrice = Nothing  'always deallocate after use...
set fso = Nothing
set vg = CreateObject("vgServices.CommandLink")
vg.RvSet $RV_LINEID, "ReadInPrice", sEntireFile
set vg = Nothing 'always deallocate after use...

 
Example 3:

The VBScript below retrieves information from an Excel spreadsheet.

Dim xlApp, xlBook, xlSht 
Dim filename, value1, value2, value3, value4

filename = "c:\Warehouse.xls"

Set xlApp = CreateObject("Excel.Application")
set xlBook = xlApp.WorkBooks.Open(filename)
set xlSht = xlApp.activesheet

value1 = xlSht.Cells(2, 1)
value2 = xlSht.Cells(2, 2)

'the MsgBox line below would be commented out in a real application
'this is just here to show how it works...

msgbox "Values are: " & value1 & ", " & value2 

xlBook.Close False
xlApp.Quit

'always deallocate after use...
set xlSht = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
 

 

Example 4:

The VBScript below saves information to an Excel spreadsheet.

Dim xlApp, xlBook, xlSht 
Dim filename, value1, value2, value3, value4

on error resume next

filename = "c:\warehouse.xls"

Set xlApp = CreateObject("Excel.Application")
set xlBook = xlApp.WorkBooks.Open(filename)
set xlSht = xlApp.activesheet

xlApp.DisplayAlerts = False

'write data into the spreadsheet
xlSht.Cells(2, 2) = "New Data"

xlBook.Save
xlBook.Close SaveChanges=True
xlApp.Close
xlApp.Quit

'always deallocate after use...
set xlSht = Nothing
Set xlBook = Nothing
Set xlApp = Nothing

 
Example 5:

The VBScript below sends keystrokes to another application running on the PC. eg: to start the Windows Calculator and make it add 1+2 the following script would be used:

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "calc"    
WScript.Sleep 100
WshShell.AppActivate "Calculator"
WScript.Sleep 200
WshShell.SendKeys "1{+}2~"
set WshShell = Nothing  'always deallocate after use...

More information on how SendKeys can be used to control other applications please see the VBScript documentation available from: msdn.microsoft.com/scripting

 

Example : Sending a Fax -  1

The VBScript below will fax out a Word document "c:\info\prices1.doc" to fax number 5554321. Note: WinFax or another scriptable faxing agent is needed in order for the scripts demonstrating faxing out to work.

Dim WordApp
Dim myWordDoc
Dim strPathDoc
Dim intRecord

Set WordApp = CreateObject("word.application")
WordApp.Visible = True
strPathDoc = "c:\info\prices1.doc"
Set myWordDoc = WordApp.Documents.Open(strPathDoc)
myWordDoc.ActiveWindow.Document.SendFax("5554321")

'always deallocate after use...
Set myWordDoc = Nothing
Set WordApp = Nothing

 
Example : Sending a Fax -  2

This example builds on previous example by using Result Variables in the VBScript. The example below uses values entered by the caller in the 'Get Fax Number' and 'Select Price List' Get Number modules. The two result variables will be replaced with their actual values before the VBScript is run.

Dim WordApp
Dim myWordDoc
Dim strPathDoc
Dim intRecord

Set WordApp = CreateObject("word.application")
WordApp.Visible = True
strPathDoc = "c:\info\prices$
RV[Select Price List].doc"
Set myWordDoc = WordApp.Documents.Open(strPathDoc)
myWordDoc.ActiveWindow.Document.SendFax("$
RV[Get Fax Number]")


'always deallocate after use...
Set myWordDoc = Nothing
Set WordApp = Nothing

Example : Sending a Fax -  3

The VBScript below will fax out a document "c:\info\prices1.doc" to all the fax numbers contained in the FaxDb database. Values could have been inserted into this database using the DB Query module.

Dim WordApp      'Object
Dim myWordDoc    'Word.Document
Dim strPathDoc   'String
Dim myRST        'Recordset
Dim myDB         'Database
Dim strFaxNumber 'String
Dim intRecord    'Long

Set WordApp = CreateObject("word.application")
Set myDB = DBEngine.Workspaces(0).Databases(0)
Set myRST = myDB.OpenRecordset("FaxDb", dbOpenDynaset)
myRST.MoveLast

WordApp.Visible = True
strPathDoc = "c:\info\prices1.doc"

Set myWordDoc = WordApp.Documents.Open(strPathDoc)

For intRecord = myRST.RecordCount To 1 Step -1
    strFaxNumber = CStr(myRST.Fields(1))
    myWordDoc.ActiveWindow.Document.SendFax(strFaxNumber)
    myRST.MovePrevious
Next intRecord


'always deallocate after use...
Set myWordDoc = Nothing
Set WordApp = Nothing
myRST.Close
Set myRST = Nothing
Set myDB = Nothing

 

Example : Sending a Fax directly with WinFax

Existing WinFax's .fxd documents can be sent directly using a VBScript below :

Dim objWinfaxSend
Set objWinfaxSend = CreateObject("WinFax.SDKSend8.0")
objWinfaxSend.SetTypeByName "Fax"
objWinfaxSend.ShowSendScreen (0)
objWinfaxSend.SetUseCover(0)
objWinfaxSend.SetSubject ("Property Information")
objWinfaxSend.SetNumber ("$RV[DestFaxNumber]")
objWinfaxSend.AddAttachmentFile("c:\faxes\6013022-flyerfax.fxd")
objWinfaxSend.SetResolution(0)
objWinfaxSend.AddRecipient
objWinfaxSend.Send (0)
objWinfaxSend.Done
Set objWinFaxSend = Nothing

 

Example 9:

The VBScript below demonstrates how the $RV_LINEIDResult Variable is used to generate a Result file from which the data is read back into VoiceGuide. Please note that using the COM function Run_ResultReturn() is a preferable way of returning information to VoiceGuide (it's faster) - but a result file can be used if there is no other way.

Dim iIndexDow, iIndexNasdaq, iIndexSP500

'Do some work here to retrieve the data and initialize
'the iIndexDow, iIndexNasdaq and iIndexSP500 variables

strResultVariables= "[IndexDow]{" & iIndexDow & "}" & _
"[IndexNasdaq]{" & iIndexNasdaq & "}" & _
"[IndexSP500]{" & iIndexSP500 & "}"

iRet = WriteResultFile(strResultVariables)

Function WriteResultFile(strResult)
  Const ForReading=1, ForWriting=2, ForAppending=8
  filename = "VGRUNRESULT_$RV_LINEID.TXT"
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set ts = fso.OpenTextFile(filename, ForWriting, True)
  ts.WriteLine(strResult)
  ts.Close
  WriteResultFile=0

  'always deallocate after use...
  set ts = Nothing
  set fso = Nothing
end function


It is recommended that the full path to the result file be specified, otherwise the Windows' current 'default' path will be used by the file subsystem - and that does not always point to the same path as the script's.

 

Example 10:

The VBScript below retrieves stock market levels from www.finance.yahoo.com and returns this data to VoiceGuide which can speak out the resultant data. (Please see the Internet Portal demo script). It uses parts of Example 4 above to write the results file.

Set IE = CreateObject("InternetExplorer.Application")
With IE
  .RegisterAsDropTarget = False
  .Visible = False
  .Silent = True
  .Navigate("finance.yahoo.com")
  While .Busy
    WScript.Sleep 100
  Wend
  With .Document.Body
    readWwwHtml = .InnerHTML
    readWwwText = .InnerText
  End With
End With
IE.Quit
Set IE = Nothing

iIndexDow = GetIntegerAfterLabel("Dow")
iIndexNasdaq = GetIntegerAfterLabel("Nasdaq")
iIndexSP500 = GetIntegerAfterLabel("S&P 500")

strResultVariables= "[MarketDow]{" & iIndexDow & "}" & _
"[MarketNasdaq]{" & iIndexNasdaq & "}" & _
"[MarketSP500]{" & iIndexSP500 & "}"

'make sure the returned data does not contain any commas
strResultVariables = replace(strResultVariables, ",", "")

set vg = CreateObject("vgServices.CommandLink")
vg.Run_ResultReturn $RV_LINEID, strResultVariables
Set vg = Nothing


function GetIntegerAfterLabel(strLabel)
  'it is assumed that the integer terminates with a decimal point
  iLblPos1= Instr(readWwwText, strLabel)
  iValuePos1 = iLblPos1 + len(strLabel)
  iValuePos2 = Instr(iValuePos1, readWwwText, ".")
  GetIntegerAfterLabel = mid(readWwwText, iValuePos1, iValuePos2-iValuePos1)
end function

 

Example 11:

You can queue an Email to be sent using VBScript as well. Script below inserts details of the message to be sent into the MS Access database EmailQue.mdb in VoiceGuide's \data\ subdirectory. VoiceGuide will then send out any emails that have been queued through that database.

Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\VoiceGuide\data\EmailQue.mdb"
cn.Execute "INSERT INTO MsgQue (ToAddress, ToName, ReturnAddress, ReturnName, MsgSubject, MsgMessage, MsgAttachment, gw1_SmtpServ) VALUES ('support@voiceguide.com', 'VoiceGuide Support', 'ivr@voiceguide.com', 'VoiceGuide IVR', 'This is a test email', 'Call received from $RV_CIDNUMBER', '', 'smtp.voiceguide.com');"
cn.Close
Set cn = Nothing

 

Example 12:

Retrieving data from an MS Access database using an SQL query, and then updating the same record with new values:

'ADO related const values from ADOVBS.INC file, usually found in: C:\Program Files\Common Files\System\ado
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3

'other related const values from the VBScript Help file at http://msdn.microsoft.com/scripting
const vbGeneralDate = 0
const vbLongDate = 1
const vbShortDate = 2
const vbLongTime = 3
const vbShortTime = 4

set vg = CreateObject("vgServices.CommandLink")
set cn = CreateObject("ADODB.Connection")
set rs = CreateObject("ADODB.Recordset")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\data\Ads.mdb"

if cn.State = 1 then
  vg.Admin_TraceLogAdd $RV_LINEID, 5, "vbs   connection to Ads.mdb made OK"
  set rs.ActiveConnection = cn
  rs.Open "SELECT TOP 1 AdID, Filename, PlayCount FROM AdList WHERE PlayCount < PlayCountMax ORDER BY LastPlayTime", cn, adOpenStatic

  if rs.RecordCount > 0 then
    vg.Admin_TraceLogAdd $RV_LINEID, 5, "vbs   records found OK"
    iAdID = rs.Fields("AdID").Value
    sFilename = rs.Fields("Filename").Value
    iPlayCount = rs.Fields("PlayCount").Value

    'Do some other processing here. eg: vg.Play_Start $RV_LINEID, sFilename

    'now update the database
    iPlayCount = iPlayCount + 1
    strDateTime = "#" & FormatDateTime(Now, vbShortDate) & " " & FormatDateTime(Now, vbLongTime) & "#"
    cn.Execute "UPDATE AdList SET PlayCount=" & iPlayCount & ", LastPlayTime=" & strDateTime & " WHERE AdID=" & iAdID
  else
    'no records could be retrieved, we can specify to play something instead here
    vg.Admin_TraceLogAdd $RV_LINEID, 5, "vbs   no records found"
  end if

else
  vg.Admin_TraceLogAdd $RV_LINEID, 5, "vbs   connection to Ads.mdb could not be made"
end if

cn.Close
Set rs = Nothing
Set cn = Nothing
Set vg = Nothing

 

Example : Retrieving data from an MS SQL Server Database:

A script like this can be used :

set vg = CreateObject("vgServices.CommandLink")
set cn = CreateObject("ADODB.Connection")
set rs = CreateObject("ADODB.Recordset")

cn.Open "Provider=SQLOLEDB;Server=DBSERVER1;UID=user;PWD=user;Database=Ads" 'MSSQL authentication

if cn.State <> 1 then
  vg.Admin_TraceLogAdd iLineId, 5, "login LeadingAd connection to database could not be made"
  vg.Run_ResultReturn iLineId, "fail"
  WScript.Quit
end if

set rs.ActiveConnection = cn
sSQL = "SELECT TOP 1 AdID, Filename, PlayCount, LastPlayTime FROM AdList WHERE PlayCount < PlayCountMax AND Active <> 0 ORDER BY LastPlayTime"
rs.Open sSQL, cn, 3

if rs.RecordCount <= 0 then
  rs.Close
  vg.Admin_TraceLogAdd iLineId, 5, "no records retrieved"
else
  iAdID = rs.Fields("AdID").Value
  sFilename = rs.Fields("Filename").Value
  iPlayCount = rs.Fields("PlayCount").Value
  dateLastPlayTime = rs.Fields("LastPlayTime").Value
  rs.Close

  sSQL = "UPDATE AdList SET PlayCount=" & iPlayCount & ", LastPlayTime=" & strDateTimeNow & " WHERE AdID=" & iAdID
  vg.Admin_TraceLogAdd iLineId, 5, "sql=[" & sSQL & "]"
  cn.Execute sSQL

  sSQL = "INSERT INTO PlayLog (AdID, CallID, PlayDateTime, PlayedFrom) VALUES (" & iAdID & ", 0, " & strDateTimeNow & ", 'AnswerCall')"
  vg.Admin_TraceLogAdd iLineId, 5, " sql=[" & sSQL & "]"
  cn.Execute sSQL
end if

cn.Close
set rs = Nothing
set cn = Nothing
set vg = Nothing
WScript.Quit

 

Example : Calling the Stored Procedures defined in the database (no parameters).

Let's assume that you have defined in your database a stored procedure names RetrieveUserNames that returns a recordset but takes no parameters.  (note this example assumes that the database connection cn and VG.CommandLink are defined outside this function) The following code will retrieve the records.

set cmd = CreateObject("ADODB.Command")
set rs = CreateObject("ADODB.Recordset")
With cmd
   .ActiveConnection = cn
   .CommandType = adCmdStoredProc
   .CommandText = "RetrieveUserNames"
   Set rs = .Execute
   'you can now access the individual fields in the recordset rs
End With
Set cmd = Nothing
Set rs = Nothing

 

Example : Calling the Stored Procedures defined in the database (with parameters).

Let's assume that you have defined in your database a parameterized stored procedure query named UpdateUser as follows:

UPDATE USERS
SET USERS.FIRSTNAME = [inFirstName], USERS.MIDDLEINITIAL = [inMiddleInitial],
USERS.LASTNAME = [inLastName], USERS.DEPARTMENT = [inDepartment],
USERS.EMAIL = [inEMail], USERS.TELEPHONE = [inTelephone],
USERS.EXTENSION = [inExtension]
WHERE (((USERS.USERNAME)=[inUserName]));
 

You should probably use a function like this as part of our VBScript to run this stored procedure (note this example assumes that the database connection and VG.CommandLink are defined outside this function):

Public Function UpdateUser(ByRef cn As Connection, ByVal Firstname As String, ByVal MiddleInitial As String, _
                           ByVal LastName As String, ByVal Department As String, ByVal Email As String, _
                           ByVal Telephone As String, ByVal Extension As String, ByVal UserName As String ) As Boolean

   Const adParamInput = 1
   Const adParamOutput = 2
   Const adInteger = 3

   Const adCmdStoredProc = 4
   Const adExecuteNoRecords = 128
   Const adVarChar = 200

   Set cmd = CreateObject("ADODB.Command")
   Dim lngRecordsAffected As Long
   With adoCmd
       .ActiveConnection = cn
      .CommandType = adCmdStoredProc
      .CommandText = "UpdateUser"
      .Parameters.Append .CreateParameter("inFirstName", adVarChar, adParamInput, 50, Firstname)
      .Parameters.Append .CreateParameter("inMiddleInitial", adVarChar, adParamInput, 2, IIf(Len(MiddleInitial) > 0, MiddleInitial, Null))
      .Parameters.Append .CreateParameter("inLastName", adVarChar, adParamInput, 50, LastName)
      .Parameters.Append .CreateParameter("inDepartment", adVarChar, adParamInput, 50, IIf(Len(Department) > 0, Department, Null))
      .Parameters.Append .CreateParameter("inEmail", adVarChar, adParamInput, 50, IIf(Len(Email) > 0, Email, Null))
      .Parameters.Append .CreateParameter("inTelephone", adVarChar, adParamInput, 50, IIf(Len(Telephone) > 0, Telephone, Null))
      .Parameters.Append .CreateParameter("inExtension", adVarChar, adParamInput, 10, IIf(Len(Extension) > 0, Extension, Null))
      .Parameters.Append .CreateParameter("inUserName", adVarChar, adParamInput, 50, UserName)
      .Execute lngRecordsAffected, , adExecuteNoRecords
      UpdateUser = CBool(lngRecordsAffected)
   End With

   Set cmd = Nothing

End Function
 

The only thing you need to do is to match the order and data type of the parameters that are 'appended' to the command object with
those of the MS Access query.

 

Example : Retrieving data from a Web Service

The example queries a web service provided by ejse.com and retrieves the weather information for a particular ZIP code. In this example 22207 (Arlington, VA) was used.

Returned data is then formatted as a Result Variable list and returned to VoiceGuide, when it may now be spoken to the caller or used for any further processing you may like.

The demo now calls MsgBox function to show the user what was retrieved as well.

You must have Microsoft's SOAP 3.0 Toolkit installed to use this. See here.


Set soapClient = CreateObject("MSSOAP.SoapClient30")
soapClient.MSSoapInit "http://www.ejse.com/WeatherService/Service.asmx?WSDL"
Set node_list = soapClient.GetWeatherInfo(22207)

For Each node In node_list
  sText = sText & "[" & node.nodeName & "]{" & node.Text & "}"
Next

set soapClient = Nothing
set node_list = Nothing

MsgBox sText

set vg = CreateObject("vgServices.CommandLink")
vg.Run_ResultReturn $RV_LINEID, sText
set vg = Nothing
 


an example of the Result Variable list returned:

[Location]{Arlington, VA}[IconIndex]{26}[Temprature]{44°F}[FeelsLike]{41°F}[Forecast]{Cloudy}[Visibility]{9.0 miles}[Pressure]{29.93 inches and rising}[DewPoint]{41°F}[UVIndex]{0 Low}[Humidity]{89%}[Wind]{From the North Northwest at 6 mph}[ReportedAt]{}[LastUpdated]{}

 

If you do not want to use the SOAP toolkit then another approach to retrieve data from the above Web Service would be to just retrieve the contents returned by this URL:

http://www.ejse.com/WeatherService/Service.asmx/GetWeatherInfo?zipCode=22207

and then just parse the returned XML to extract the required data. Similar approach would also work for all other Web Services.

 

Other Resources:

http://www.visualbasicscript.com
http://www.tek-tips.com/threadminder.cfm?pid=329
http://www.codebox.8m.com/vbscript.htm
http://www.cetus-links.org/oo_vbscript.html

 

Notes:

After the Result Variables have been replaced in the VBScript, the new VBScript will be saved in the data directory, named as vbs_LineId_ThisCallScriptIndex.vbs Viewing this file will allow you to confirm that Result Variable replacement was done correctly.

VBScripts are executed by just double clicking on the .vbs file, or by using the wscript.exe utility.

Converted from CHM to HTML with chm2web Pro 2.7 (unicode)