MsScriptControl.Run error

  • Thread starter Thread starter DraguVaso
  • Start date Start date
D

DraguVaso

Hi,

I have a VBScript that I want to run from my VB.NET application.
I initialize everything like this:

AxScriptControl1.Language = "VBScript"
AxScriptControl1.Reset()
AxScriptControl1.AddCode(strText)
AxScriptControl1.AddObject("Toolbar", AxToolbar1)

AxToolbar1 is a component, and strText has the whole script (see later).

When I try to run a fucntion in my script as following:
"AxScriptControl1.Run("OnMailSuccess", Nothing)" I get this error:
"Invalid pointer at MSScriptControl.IScriptControl.Run(String
ProcedureName, Object[]& Parameters)
at AxMSScriptControl.AxScriptControl.Run(String procedureName, Object[]&
parameters)"

When I try like this:
"Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim obj As New Object
obj = ""
AxScriptControl1.Run("OnMailSuccess", obj)
End Sub
"
I got this error:
"Specified cast is not valid. at
VocalcomCetelem.frmAgent.Button1_Click(Object sender, EventArgs e)"

I guess it's something about the error?

I'll give you the whoel scritp too in case it would help.

Thansk a lot in advance,

Pieter



strText = "Dim golApp
Dim objInspector

Sub OnLoad

Set golApp = CreateObject("Outlook.Application.8") 'New
Outlook.Application
End Sub


Sub OnWrapupEnd
on error resume next
Application.Navigate ""
if not objInspector is nothing then
objInspector.Close(1)
end if
on error goto 0
End Sub

Sub OnMailSuccess
Dim gnspNameSpace
Dim gmfInbox
Dim gmiItem

Set gnspNameSpace = golApp.GetNamespace("MAPI")

for j=1 to gnspNameSpace.Folders.Count
if instr(1,gnspNameSpace.Folders.Item(j).Name,"Fax")>0 then

set gmfInbox = gnspNameSpace.Folders.Item(j).Folders.Item(4)
For i = 1 To gmfInbox.Items.Count

Set gmiItem = gmfInbox.Items.Item(i)
If gmiItem.EntryID = Toolbar.CallInformation(1).ItemID Then
Set objInspector = gmiItem.GetInspector
objInspector.Display
Exit For
End If
Next

end if
next

End Sub"
 
Back
Top