S
Scott Herter
I created a simple Windows Forms app (strongly named)
in VB .NET that automates MS Word XP. The app handles
the Word.Quit event...however my event handler for this
is not being called when my app is launched from
a url on a web page (works fine when I run my app stand
alone). I have a code group that I created for my app
in order to avoid a security exception when creating the
new Word.Application (I created a code group with the
membership condition tied to the strong name of my app
and set the permission set to "FullTrust").
I originally ran into this problem while trying to do
this with a UserControl embedded in a web page, but
found I could reproduce the behavior with a Windows
Forms App launched from a web page.
So can anyone tell me why the Quit event won't fire when
my app is launched from a url?
Here is the code from my Windows Forms app...
Imports Microsoft.Office.Core
Imports Microsoft.Office.Interop
Public Class Form1
Inherits System.Windows.Forms.Form
' Main member var for getting at Word object model
Private WithEvents m_wordApp As Word.ApplicationClass
Private Sub wordApp_Quit() Handles
m_wordApp.ApplicationEvents2_Event_Quit
m_wordApp = Nothing
MsgBox("Word Quit Event", MsgBoxStyle.SystemModal Or
MsgBoxStyle.Information)
End Sub
Private Sub btnLaunchWord_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnLaunchWord.Click
If m_wordApp Is Nothing Then
m_wordApp = New Word.Application()
m_wordApp.Visible = True
End If
End Sub
End Class
in VB .NET that automates MS Word XP. The app handles
the Word.Quit event...however my event handler for this
is not being called when my app is launched from
a url on a web page (works fine when I run my app stand
alone). I have a code group that I created for my app
in order to avoid a security exception when creating the
new Word.Application (I created a code group with the
membership condition tied to the strong name of my app
and set the permission set to "FullTrust").
I originally ran into this problem while trying to do
this with a UserControl embedded in a web page, but
found I could reproduce the behavior with a Windows
Forms App launched from a web page.
So can anyone tell me why the Quit event won't fire when
my app is launched from a url?
Here is the code from my Windows Forms app...
Imports Microsoft.Office.Core
Imports Microsoft.Office.Interop
Public Class Form1
Inherits System.Windows.Forms.Form
' Main member var for getting at Word object model
Private WithEvents m_wordApp As Word.ApplicationClass
Private Sub wordApp_Quit() Handles
m_wordApp.ApplicationEvents2_Event_Quit
m_wordApp = Nothing
MsgBox("Word Quit Event", MsgBoxStyle.SystemModal Or
MsgBoxStyle.Information)
End Sub
Private Sub btnLaunchWord_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnLaunchWord.Click
If m_wordApp Is Nothing Then
m_wordApp = New Word.Application()
m_wordApp.Visible = True
End If
End Sub
End Class