0

以前にこれがあったことは知っていますが、それを回避する方法を思い出せません。

1 つのことを除けば、正常に動作するマネージ コード アドインを作成しました。Access アプリケーションを閉じようとしても、タスクを終了しない限り、アプリケーション ウィンドウは引き続き表示されます。Visual Studio 2010 を使用してアドインをデバッグしているときに、デバッグを停止すると正常に終了します。

on disconnect イベントの一部として、すべての変数を何も設定していません。

Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection
    'On Error Resume Next
    If Not MenuCommandControls Is Nothing Then MenuCommandControls.Delete()
    If Not MenuCommandDimensionVariable Is Nothing Then MenuCommandDimensionVariable.Delete()
    If Not MenuCommandFields Is Nothing Then MenuCommandFields.Delete()
    If Not MenuCommandForms Is Nothing Then MenuCommandForms.Delete()
    If Not MenuCommandParseSQL Is Nothing Then MenuCommandParseSQL.Delete()
    If Not MenuCommandQueries Is Nothing Then MenuCommandQueries.Delete()
    If Not MenuCommandReports Is Nothing Then MenuCommandReports.Delete()
    If Not MenuCommandTables Is Nothing Then MenuCommandTables.Delete()
    If Not MenuCommandVariables Is Nothing Then MenuCommandVariables.Delete()
    If Not searchForm Is Nothing Then searchForm.Close() : searchForm = Nothing
    If Not ObjectSetting Is Nothing Then ObjectSetting = Nothing
    If Not AccessInst Is Nothing Then AccessInst = Nothing
    If Not addInInstance Is Nothing Then addInInstance = Nothing
    'If Not FormParseSQL Is Nothing Then FormParseSQL = Nothing
    applicationObject.Quit(Access.AcQuitOption.acQuitPrompt)
    If Not applicationObject Is Nothing Then applicationObject = Nothing

End Sub
4

1 に答える 1

0

xをオプションの整数としてサブルーチンに追加します

[アプリの終了]ボタンを作成し、x = 1に設定すると、サブルーチンが呼び出され、オプションのx値が渡されます。application.quitコマンドを配置します

サブルーチンの下部で、x = 1の場合、application.quit。

アプリの終了ボタンからONdisconnectサブルーチンを呼び出します。

アプリケーションを終了する他のすべての方法を無効にします。

簡単、シンプル、機能的。

このようにして、切断が発生したとき、またはアプリケーションを閉じたときに、Ondisconnectが機能します。

于 2012-08-14T17:21:09.107 に答える