cancel
Showing results for 
Search instead for 
Did you mean: 

vba sapgui (MsAccess) application to convert to run in VB.NET missing imports files!

former_member576315
Discoverer
0 Kudos

I'm trying to convert code I wrote in VBA (from Access 2013) to a new VB.NET platform. I'm assuming I need to import a SAPGUI reference but can't find where to find it! I went into the package manager and installed the ... Install-Package SAP.GUI.Scripting.net -Version 1.0.0

And still can't find what I need to do next!

Here is the code I need to convert!

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

<code>Dim stat1, stat2, TEDATstr AsStringDim statl, stst2 AsInteger
Session_number_max =5'the maximum number of possible SAP sessionsDim session_number_(5)OnErrorGoTo 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 -1If Connection.Children.Count =0Then
 MsgBox ("Costs =")& session_number_all
 'GoTo ErreurEndIfFor i =0To Session_number_max -1
     session_number_(i)=0NextFor session_number =0To session_number_all
     Set session = Connection.Children(Int(session_number))
     session_number_(session.Info.SessionNumber)=     session.Info.SessionNumber
NextIf session_number_all < Session_number_max -1Then
     session.CreateSession
     Do'WScript.sleep 500If Connection.Children.Count - session_number_all >=2ThenExitDoLoopOnErrorResumeNext
     Error_number =1For session_number =0To session_number_all +1
          Err.Clear
          Set session = Connection.Children(Int(session_number +1))If Err.Number >0Or Err.Number <0ThenExitForIf session_number_(session.Info.SessionNumber)=0Then
            Error_number =0ExitForEndIfNextOnErrorGoTo0Else
 MsgBox "New session not possible!"EndIf
session.FindById("wnd[0]").resizeWorkingPane 150,31,False
session.FindById("wnd[0]/tbar[0]/okcd").Text ="cn53n"
session.FindById("wnd[0]").SendVKey 0OnErrorResumeNext
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 0EndIf
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 =0To GridView.RowCount -1If GridView.GetCellValue(i,"MLSTN")="NRTB"ThenMe.datenrtb = GridView.GetCellValue(i,"TEDAT")EndIfIf GridView.GetCellValue(i,"MLSTN")="FCOM"ThenMe.datefcom = GridView.GetCellValue(i,"TEDAT")EndIfIf GridView.GetCellValue(i,"MLSTN")="NISR"ThenMe.datencom = GridView.GetCellValue(i,"TEDAT")EndIfNext 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 =0Set 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 =NothingExitSub

            TempVars!enum=5ExitSub
    SapGuiAuto =Nothing
    SAP =Nothing
    session =Nothing

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

Thanks

Pete

Accepted Solutions (0)

Answers (0)