Está en la página 1de 2

Public Sub Executar()

Dim shtRESER As Worksheet


Dim objTable As Object
Dim intRwVisible As Integer
Dim intScrollbar As Integer
Dim i, x, z As Long

'Configuración de la variable que representa la hoja de cálculo


Set shtRESER = ThisWorkbook.Sheets("RESER")

Session.findById("wnd[0]").maximize
'Configurando la transacción
session.findById("wnd[0]/tbar[0]/okcd").text = "/nmb21"

'Enviando conformacion con enter


Session.findById("wnd[0]").sendVKey 0

'Fecha del documento de llenado


session.findById("wnd[0]/usr/ctxtRM07M-RSDAT").text = shtRESER.Cells(2, 3).Value

'Insertar clase de movimiento


session.findById("wnd[0]/usr/ctxtRM07M-BWART").text = shtRESER.Cells(3, 3).Value

'Insertar Centro de Trabajo


session.findById("wnd[0]/usr/ctxtRM07M-WERKS").text = shtRESER.Cells(4, 3).Value

session.findById("wnd[0]/usr/ctxtRM07M-WERKS").setFocus
session.findById("wnd[0]/usr/ctxtRM07M-WERKS").caretPosition = 4
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtRKPF-UMLGO").text = "A002"

'Empezar a publicar artículos


'Capturando la última línea llena de la columna B
i = shtRESER .Range("B300").End(xlUp).Row

'Registro de variable Z
z = 0

'Variable sentada que representa la tabla de elementos en pantalla


Set objTable = session.findById("wnd[0]/usr/sub:SAPMM07R:0521")

'Capturar la cantidad de líneas visibles por pantalla


intRwVisible = objTable.VisibleRowCount

For x= 8 To i
voltar
If z = intRwVisible Then
intScrollbar = intScrollbar + intRwVisible

session.findById("wnd[0]/usr/sub:SAPMM07R:0521") .verticalScrollbar.Position =
intScrollbar
z = 0
Else
'Regristro de material
session.findById("wnd[0]/usr/sub:SAPMM07R:0521/ctxtRESB-MATNR[0," & z &
"]").text = shtRESER.Cells(x, 2).Value
'Registro de Cantidad
session.findById("wnd[0]/usr/sub:SAPMM07R:0521/txtRESB-ERFMG[0," & z &
"]").text = shtRESER.Cells(x, 3).Value
session.findById("wnd[0]/usr/sub:SAPMM07R:0521/ctxtRESB-ERFME[0," & z &
"]").text = shtRESER.Cells(x, 4).Value

session.findById("wnd[0]/usr/sub:SAPMM07R:0521/ctxtRESB-WERKS[0," & z &


"]").text = shtRESER.Cells(x, 5).Value

session.findById("wnd[0]/usr/sub:SAPMM07R:0521/ctxtRESB-LGORT[0," & z &


"]").text = shtRESER.Cells(x, 6).Value

session.findById("wnd[0]/usr/sub:SAPMM07R:0521/ctxtRESB-CHARG[0," & z &


"]").text = shtRESER.Cells(x, 7).Value

z = z + 1
End If

También podría gustarte