I made a Windows app in C# using .NET VS 2003. It's loosely related to a
group of InfoPath forms I made, so I want to add a button on a custom
toolbar to launch this app from within InfoPath. It's just a convenience
for my users. I learned how to add the button by editing the XSF file,
but how to I launch the Windows app from that button?
Ideal would be to install this button so that it's independent of the
form loaded, because there's a lot of form templates I have to modify
otherwise (but this is not a requirement).
Gustaf
Using the WScript.Shell will let you start other applications:
var WshShell = new ActiveXObject("WScript.Shell");
var oExec = WshShell.Exec("calc");
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/w
slrfexecmethod.asp
You will get a security warning when the script runs, and might need to make
your form run under full trust.
KjellSJ
http://kjellsj.blogspot.com
> I made a Windows app in C# using .NET VS 2003. It's loosely related to a
> group of InfoPath forms I made, so I want to add a button on a custom
[quoted text clipped - 7 lines]
>
> Gustaf
Gustaf Liljegren - 10 May 2005 13:47 GMT
> Using the WScript.Shell will let you start other applications:
> var WshShell = new ActiveXObject("WScript.Shell");
[quoted text clipped - 4 lines]
> You will get a security warning when the script runs, and might need to make
> your form run under full trust.
When I run this script from the InfoPath Script Editor, all I get is the
contents of script.js in the web browser.
I have made the button in the XSF file like this:
<xsf:toolbar name="myToolbar" caption="My Toolbar">
<xsf:button caption="My Button" icon="1" tooltip="My Tooltip"
name="MyFunction"/>
</xsf:toolbar>
First, the icon doesn't show up. I tried adding a 16x16 BMP in the
resource file from InfoPath, but writing the filename in the icon
attribute didn't help. One book suggested this is an integer, so writing
"1" there seems logical.
Secondly, nothing happens when I press the button. There seem to be no
connection between the name attribute and the MyFunction function in
script.js.
Gustaf
1.add code to the click event of your button
2.instantiate your windows app
MyWindowsApp myApp = new MyWindowsApp(); // this will likely require
a 'using' reference
3. call the myApp.Show() or myApp.ShowDialog() method