Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub SAP()
- Dim sap As Object
- Dim conn As Object
- Set sap = CreateObject("SAP.Functions")
- Set conn = sap.Connection
- conn.System = "S0P"
- conn.Client = ""
- conn.User = ""
- conn.Password = ""
- conn.Language = "PT"
- If conn.logon(0, False) <> True Then
- MsgBox "Logon to the SAP system is not possible", vbOKOnly, "Comment"
- End If
- Set SapGuiAuto = GetObject("SAPGUI") 'Utiliza o objeto da interface gráfica do SAP
- Set SAPApp = SapGuiAuto.GetScriptingEngine 'Conecta ao SAP que está rodando no momento
- Set SAPCon = SAPApp.Children(0) 'Encontra o primeiro sistema que está conectado
- Set session = SAPCon.Children(0) 'Encontra a primeira sessão (janela) dessa conexão
- If Not IsObject(Application) Then
- Set SapGuiAuto = GetObject("SAPGUI")
- End If
- If Not IsObject(Connection) Then
- End If
- If Not IsObject(session) Then
- End If
- If IsObject(WScript) Then
- WScript.ConnectObject session, "on"
- WScript.ConnectObject Application, "on"
- End If
- session.findById("wnd[0]").maximize
- Dim objExcel
- Dim objSheet, intRow, aux, Log
- Set objExcel = GetObject(, "Excel.Application")
- Set objSheet = objExcel.ActiveWorkbook.ActiveSheet
- DataInicial = Range("H2")
- DataFinal = Range("H3")
- session.findById("wnd[0]/tbar[0]/okcd").Text = "/NMB51"
- End Sub
- Set SapGuiAuto = GetObject("SAPGUI")
Add Comment
Please, Sign In to add comment