无法将 VBA SAPGUI 代码转换为 VB.NET 无法找到正确的导入库

Trouble converting VBA SAPGUI code to VB.NET can't find proper imports libraries

我正在尝试将我在 VBA(来自 Access 2013)中编写的代码转换为新的 VB.NET 平台。我假设我需要导入一个 SAPGUI 参考,但找不到在哪里可以找到它! 我进入包管理器并安装了... 安装包 SAP.GUI.Scripting.net - 版本 1.0.0

而且仍然找不到我下一步需要做什么!

这是我需要转换的代码!

============================================= =

Dim stat1, stat2, TEDATstr As String
Dim statl, stst2 As Integer
Session_number_max = 5  'the maximum number of possible SAP sessions
Dim session_number_(5)
On Error GoTo Erreur:
Set SapGuiAuto = GetObject("SAPGUI")

Set SAP = SapGuiAuto.GetScriptingEngine
Set Connection = SAP.Children(0)
Set session = Connection.Children(0)

'-- new session connect -----------------------------------------
session_number_all = Connection.Children.Count - 1

If Connection.Children.Count = 0 Then
 MsgBox ("Costs =") & session_number_all
 'GoTo Erreur
 End If
For i = 0 To Session_number_max - 1
     session_number_(i) = 0
Next

For session_number = 0 To session_number_all
     Set session = Connection.Children(Int(session_number))
     session_number_(session.Info.SessionNumber) =     session.Info.SessionNumber
Next

If session_number_all < Session_number_max - 1 Then
     session.CreateSession
     Do
      'WScript.sleep 500
      If Connection.Children.Count - session_number_all >= 2 Then Exit Do
     Loop
     On Error Resume Next
     Error_number = 1
     For session_number = 0 To session_number_all + 1
          Err.Clear
          Set session = Connection.Children(Int(session_number + 1))
          If Err.Number > 0 Or Err.Number < 0 Then Exit For
                   If session_number_(session.Info.SessionNumber) = 0 Then
            Error_number = 0
            Exit For
         End If

     Next
     On Error GoTo 0
Else
 MsgBox "New session not possible!"
End If



session.FindById("wnd[0]").resizeWorkingPane 150, 31, False
session.FindById("wnd[0]/tbar[0]/okcd").Text = "cn53n"
session.FindById("wnd[0]").SendVKey 0
On Error Resume Next
session.FindById ("wnd[1]/usr/ctxtTCNT-PROF_DB")
If (Err.Number = 0) Then
session.FindById("wnd[1]/usr/ctxtTCNT-PROF_DB").Text = "000000000001"
session.FindById("wnd[1]/usr/ctxtTCNT-PROF_DB").CaretPosition = 12
session.FindById("wnd[1]").SendVKey 0
End If
session.FindById("wnd[0]/usr/ctxtCN_PROJN-LOW").Text = Left(Me.envelope, 9)
session.FindById("wnd[0]").SendVKey 0
session.FindById("wnd[0]/usr/ctxtCN_NETNR-LOW").Text =     Trim(CStr(Me.reseau))
session.FindById("wnd[0]/usr/ctxtCN_NETNR-LOW").SetFocus
session.FindById("wnd[0]/usr/ctxtCN_NETNR-LOW").CaretPosition = 7
session.FindById("wnd[0]/usr/ctxtP_DISVAR").Text = "/MJ CN53N"
session.FindById("wnd[0]").SendVKey 0
session.FindById("wnd[0]/tbar[1]/btn[8]").press


 session.FindById("wnd[0]/usr/cntlALVCONTAINER/shellcont/shell").CurrentCellCo    lumn = "LST_ACTDT"

Set GridView =     session.FindById("wnd[0]/usr/cntlALVCONTAINER/shellcont/shell")

For i = 0 To GridView.RowCount - 1
If GridView.GetCellValue(i, "MLSTN") = "NRTB" Then


Me.datenrtb = GridView.GetCellValue(i, "TEDAT")
End If
If GridView.GetCellValue(i, "MLSTN") = "FCOM" Then
Me.datefcom = GridView.GetCellValue(i, "TEDAT")
End If
If GridView.GetCellValue(i, "MLSTN") = "NISR" Then
Me.datencom = GridView.GetCellValue(i, "TEDAT")
End If


Next i
session.FindById("wnd[0]/tbar[1]/btn[8]").press
session.FindById("wnd[0]/tbar[0]/btn[15]").press

session.FindById("wnd[0]").resizeWorkingPane 150, 31, False
session.FindById("wnd[0]/tbar[0]/okcd").Text = "cn46n"
session.FindById("wnd[0]").SendVKey 0
session.FindById("wnd[0]/usr/ctxtCN_PROJN-LOW").Text = Left(Me.envelope, 9)
session.FindById("wnd[0]/usr/ctxtCN_NETNR-LOW").Text = CStr(Me.reseau)
session.FindById("wnd[0]/usr/ctxtCN_NETNR-LOW").SetFocus
session.FindById("wnd[0]/usr/ctxtCN_NETNR-LOW").CaretPosition = 7
session.FindById("wnd[0]/tbar[1]/btn[8]").press 

i = 0

 Set GridView =     session.FindById("wnd[0]/usr/cntlALVCONTAINER/shellcont/shell")
stat2 = Len(GridView.GetCellValue(0, "STATXT"))
Me.etat_courrant = Mid(GridView.GetCellValue(0, "STATXT"), stat1 + 3, stat2 - stat1)
Me.etat_en_date_de = Now()
session.FindById("wnd[0]/tbar[0]/btn[15]").press
session.FindById("wnd[0]/tbar[0]/btn[15]").press
    SapGuiAuto = Nothing
    SAP = Nothing
    session = Nothing
    Exit Sub

            TempVars!enum = 5
    Exit Sub
    SapGuiAuto = Nothing
    SAP = Nothing
    session = Nothing

============================================= =

谢谢

皮特

我必须安装来自 SAP 的 .net 连接器,不幸的是,它需要 S-USER ID。终于设法追踪联系我公司的谁来订购一个并下载 .NET 连接器!现在工作正常!只是缺少连接器!

https://support.sap.com/en/product/connectors/msnet.html

皮特