I am new at this so try not to laugh too hard if you find my ignorance amusing.
I've been teaching for 30 years and I have observed that one of the toughest obstacles for a student to overcome is others laughng at a sincere question. So please be kind. i realize there are MANY of you out there who are much smarter than I in this area. I'm OK with that. I'm a humble guy. :-)
I am trying to run a program via a button in an InfoPath form.
I have set security to Full Trust.
I have added Reference... Windows Script Host Object Model
the button code is as follows:
Public Sub CTRL1_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)Dim WshShell As IWshRuntimeLibrary.IWshShell
Dim CreateObjectWshShell = Createobject("WScript.Shell")
WshShell.Run(
"c:\icmxfer.exe")
End Sub
I have no errors reported in the code windows I was getting an error before I added the "Dim CreateObject"
Error 1 Name 'Createobject' is not declared. C:\VB4InfoPath\test456\FormCode.vb 34 24 test456
I realize what I have done is probably bogus but I am not familiar enough (yet) with the appropriate way to code this.
I do have 2 warnings:
Warning 1 Variable declaration without an 'As' clause; type of Object assumed. C:\VB4InfoPath\test456\FormCode.vb 33 17 test456
Warning 2 Variable 'CreateObject' is used before it has been assigned a value. A null reference exception could result at runtime. C:\VB4InfoPath\test456\FormCode.vb 34 24 test456
I am getting the following errors when I test the button.
System.NullReferenceException
Object variable or With block variable not set.
at Microsoft.VisualBasic.CompilerServices.Symbols.Container..ctor(Object Instance)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.InternalLateIndexGet(Object Instance, Object[] Arguments, String[] ArgumentNames, Boolean ReportErrors, ResolutionFailure& Failure)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateIndexGet(Object Instance, Object[] Arguments, String[] ArgumentNames)
at test456.FormCode.CTRL1_5_Clicked(Object sender, ClickedEventArgs e)
at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)