|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub test()
If Not IsObject(Applicationa) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set Applicationa = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = Applicationa.Children(0)
End If
If Not IsObject(session) Then
Set session = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject Applicationa, "on"
End If
M = Range("A" & Sheet1.Rows.Count).End(3).Row
Range("A2:E" & M).Interior.ColorIndex = 0
For i = 2 To M
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "ZLWMLBL"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtP_MATNR").Text = Cells(i, 1)
session.findById("wnd[0]/usr/ctxtP_SIZE").Text = Cells(i, 2)
session.findById("wnd[0]/usr/ctxtP_CAT").Text = Cells(i, 3)
session.findById("wnd[0]/usr/ctxtP_WERKS").Text = "CN01"
session.findById("wnd[0]/usr/ctxtP_LGORT").Text = Cells(i, 5)
session.findById("wnd[0]/usr/txtP_LFIMG").Text = Cells(i, 4)
session.findById("wnd[0]").sendVKey 8
Range("A" & i & ":E" & i).Interior.ColorIndex = 3
Next
End Sub
|
|