2016-09-15 56 views
0

這是我的第一個問題,所以請在我身上輕鬆一下。關閉來自Access VBA的WRQ Reflection實例

我的公司正在使用Reflection for UNIX和OpenVMS,我正在構建一個與軟件交互的數據庫,因爲我無法訪問Reflection應用程序背後的數據庫(需要太多的授權等等......) 。

我現在正在使用MS Access 2013並在VBA中編碼。我的主要問題是以乾淨的方式關閉Reflection實例。

下面的代碼工作正常,我:

Sub Test() 

Dim strUserId As String 
Dim MyObject As Reflection2.Session 
Set MyObject = GetObject(Path) 

strUserId = InputBox("Enter user ID.") 

ContractNum = InputBox("Enter a contract number :") 

With MyObject 
    .Visible = True 
    .Connect 
    .Transmit strUserId 
    .TransmitTerminalKey rcVtEnterKey 
    .Transmit ContractNum 
    .TransmitTerminalKey rcVtEnterKey 
    sContractNum = .GetText(1, 18, 1, 28) 
    'Do other shit 
End With 

**Exit Reflection** 

Set MyObject = Nothing 

End Sub 

我曾嘗試以下方法:

MyObject.Close ==> Returns : "Run-time error '438': Object doesn't support this property of method" 
MyObject.Exit ==> Returns : "Run-time error '438': Object doesn't support this property of method" 
MyObject.Quit ==> Returns : "Run-time error '10097': This function not available when running Reflection as a document object." 

有:MyObject.ConfirmExit = True但它說,它只是確認並沒有關閉。

無論如何,我希望有人會在通過Shell命令進行硬關閉之前提供幫助(在Google上我不會很難找到)。

謝謝!

回答

0

發現使用下面的代碼的方式,這是一個相當苛刻的收盤但目前工作正常:

Function TaskKill(sTaskName) 
    TaskKill = CreateObject("WScript.Shell").Run("taskkill /f /im " & sTaskName, 0, True) 
End Function 

If TaskKill("r2win.exe") = 0 Then MsgBox "Terminated" Else MsgBox "Failed" 

希望幫助