on 03-01-2012 4:14 PM
Hello all,
Good day.
I am using record macro code to create PO in excel.
Coding Working fine.
But once PO Created i want the PO no in the Excel Column B.
Please Help.
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.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 application, "on"
End If
Set xclapp = CreateObject("Excel.Application")
Set xclapp = CreateObject("Excel.Application")
Set xclwbk = xclapp.Workbooks.Open("c:\tmp\prices.xlsx")
set xclsht = xclwbk.Sheets("Sheet1")
i = 2
While (not xclsht.Cells(i, 1).Value = "")
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").text = "/nm2n"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0016/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3212/cntlGRIDCONTROL/shellcont/shell").modifyCell 0,"BNFPO",xclsht.cells(i,1).Value
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[1]/usr/btnSPOP-VAROPTION1").press
i = i + 1
Wend
msgbox "All " & cstr(xclapp.ActiveCell.SpecialCells(11).Row - 1) & " Excel rows have been processed."
Set xclwbk = Nothing
Set xclsht = Nothing
xclapp.Quit
set xclapp = Nothing
Edited by: hpvinu on Mar 1, 2012 5:14 PM
Once PO Saved
in the bottom " MSG will Come " Like PO XXXXX Created.
I want the MSG in my Excel B Column.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
late but i hope I can be of service ...
you can read the "Bottom" (which is actually The Statusbar as Following:
session.findbyid("wnd[0]/usr/sbar").MessageId -> or
session.findbyid("wnd[0]/usr/sbar").Text (the displayed Text) and then you just have to look for
PO Number in the returned String:
PO_Number = session.findbyid("wnd[0]/usr/sbar").Text
dummy() = Split("PO_Number"," ")
xclsht.cells(i,2).Value = dummy(1)
This should work in case th PO-Number is the second thing in the Statusline Text
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.