Need help returning Status bar in excel from SAP

Hackermen

New Member
Joined
Mar 28, 2018
Messages
1
Hello,
I'm having some issue's getting my code to return the status bar value from VA41 in SAP as the contract is completed. The status bar will be the contract number entered so it is crucial that I get this in. I've posted my code below but all my attempts have failed so I left off the code I was using as I tried to mirror others.


Dim App, Connection, session As Object
Set SapGuiAuto = GetObject("SAPGUI")
Set App = SapGuiAuto.GetScriptingEngine
Set Connection = App.Children(0)
Set session = Connection.Children(0)

Set xclapp = CreateObject("Excel.Application")
Set xclwbk = xclapp.Workbooks.Open("C:\Users\a059139\Desktop\script testingxlsx.xlsm")
Set xclsht = xclwbk.Sheets("Sheet1")

'For i = 2 To xclapp.ActiveCell.SpecialCells(11).Row
'For j = 1 To xclapp.ActiveCell.SpecialCells(11).Column
'If j = 3 Then SalesOrganization = xclsht.Cells(i, j).Value
'If j = 4 Then Division = xclsht.Cells(i, j).Value
'If j = 5 Then DistributionChannel = xclsht.Cells(i, j).Value
'If j = 7 Then CustomerNumber = xclsht.Cells(i, j).Value
'If j = 9 Then ShipNumber = xclsht.Cells(i, j).Value
'If j = 12 Then Plant = xclsht.Cells(i, j).Value
'If j = 14 Then Incoterm = xclsht.Cells(i, j).Value
'If j = 15 Then Route = xclsht.Cells(i, j).Value
'If j = 16 Then StartDate = xclsht.Cells(i, j).Value
'If j = 17 Then EndRange = xclsht.Cells(i, j).Value
'If j = 19 Then Material = xclsht.Cells(i, j).Value
'If j = 22 Then Quantity = xclsht.Cells(i, j).Value
'If j = 31 Then FlatPrice = xclsht.Cells(i, j).Value
'If j = 37 Then FinalPrice = xclsht.Cells(i, j).Value

session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nva41"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtVBAK-AUART").Text = "zepc"
session.findById("wnd[0]/usr/ctxtVBAK-VKORG").Text = Range("C2")
session.findById("wnd[0]/usr/ctxtVBAK-VTWEG").Text = Range("E2")
session.findById("wnd[0]/usr/ctxtVBAK-SPART").Text = Range("D2")
session.findById("wnd[0]/usr/ctxtVBAK-SPART").SetFocus
session.findById("wnd[0]/usr/ctxtVBAK-SPART").caretPosition = 2
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/subSUBSCREEN_HEADER:SAPMV45A:4021/subPART-SUB:SAPMV45A:4701/ctxtKUAGV-KUNNR").Text = Range("F2")
session.findById("wnd[0]/usr/subSUBSCREEN_HEADER:SAPMV45A:4021/subPART-SUB:SAPMV45A:4701/ctxtKUWEV-KUNNR").Text = Range("G2")
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4406/ssubHEADER_FRAME:SAPMV45A:4440/subSUBSCREEN_VERTRAG:SAPLV45W:0400/ctxtVEDA-VBEGDAT").Text = Range("K2")
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4406/ssubHEADER_FRAME:SAPMV45A:4440/subSUBSCREEN_VERTRAG:SAPLV45W:0400/ctxtVEDA-VENDDAT").Text = Range("L2")
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4406/subSUBSCREEN_TC:SAPMV45A:4906/tblSAPMV45ATCTRL_U_ERF_LIEFERPLAN/ctxtRV45A-MABNR[1,0]").Text = Range("M2")
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4406/subSUBSCREEN_TC:SAPMV45A:4906/tblSAPMV45ATCTRL_U_ERF_LIEFERPLAN/txtVBAP-ZMENG[2,0]").Text = Range("N2")
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4406/subSUBSCREEN_TC:SAPMV45A:4906/tblSAPMV45ATCTRL_U_ERF_LIEFERPLAN/ctxtVBAP-ZIEME[3,0]").Text = "lb"
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4406/subSUBSCREEN_TC:SAPMV45A:4906/tblSAPMV45ATCTRL_U_ERF_LIEFERPLAN/ctxtVBAP-WERKS[47,0]").Text = Range("H2")
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4406/subSUBSCREEN_TC:SAPMV45A:4906/tblSAPMV45ATCTRL_U_ERF_LIEFERPLAN/ctxtVBAP-WERKS[47,0]").SetFocus
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4406/subSUBSCREEN_TC:SAPMV45A:4906/tblSAPMV45ATCTRL_U_ERF_LIEFERPLAN/ctxtVBAP-WERKS[47,0]").caretPosition = 4
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4406/subSUBSCREEN_TC:SAPMV45A:4906/tblSAPMV45ATCTRL_U_ERF_LIEFERPLAN/ctxtRV45A-MABNR[1,0]").SetFocus
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4406/subSUBSCREEN_TC:SAPMV45A:4906/tblSAPMV45ATCTRL_U_ERF_LIEFERPLAN/ctxtRV45A-MABNR[1,0]").caretPosition = 9
session.findById("wnd[0]").sendVKey 2
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\04").Select
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\04/ssubSUBSCREEN_BODY:SAPMV45A:4452/ctxtVBAP-ROUTE").Text = Range("J2")
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\04/ssubSUBSCREEN_BODY:SAPMV45A:4452/ctxtVBAP-ROUTE").SetFocus
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\04/ssubSUBSCREEN_BODY:SAPMV45A:4452/ctxtVBAP-ROUTE").caretPosition = 2
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\05").Select
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\05/ssubSUBSCREEN_BODY:SAPMV45A:4453/ctxtVBKD-INCO1").Text = Range("I2")
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\06").Select
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\06/ssubSUBSCREEN_BODY:SAPLV69A:5201/subSUBSCREEN_PRICING:SAPLV69A:6201/tblSAPLV69ATCTRL_KONDITIONEN/txtKOMV-KBETR[4,3]").Text = Range("R2")
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\06/ssubSUBSCREEN_BODY:SAPLV69A:5201/subSUBSCREEN_PRICING:SAPLV69A:6201/tblSAPLV69ATCTRL_KONDITIONEN/ctxtRV61A-KOEIN[5,3]").Text = "USDn"
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\06/ssubSUBSCREEN_BODY:SAPLV69A:5201/subSUBSCREEN_PRICING:SAPLV69A:6201/tblSAPLV69ATCTRL_KONDITIONEN/txtKOMV-KBETR[4,3]").SetFocus
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\06/ssubSUBSCREEN_BODY:SAPLV69A:5201/subSUBSCREEN_PRICING:SAPLV69A:6201/tblSAPLV69ATCTRL_KONDITIONEN/txtKOMV-KBETR[4,3]").caretPosition = 16
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\06/ssubSUBSCREEN_BODY:SAPLV69A:5201/subSUBSCREEN_PRICING:SAPLV69A:6201/subSUBSCREEN_WITH_VIEWSELECTION:SAPLV69A:6203/cmbVFPRCS_VIEWKEY-VIEWKEY").SetFocus
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\06/ssubSUBSCREEN_BODY:SAPLV69A:5201/subSUBSCREEN_PRICING:SAPLV69A:6201/subSUBSCREEN_WITH_VIEWSELECTION:SAPLV69A:6203/cmbVFPRCS_VIEWKEY-VIEWKEY").Key = "9002"
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\06/ssubSUBSCREEN_BODY:SAPLV69A:5201/subSUBSCREEN_PRICING:SAPLV69A:7201/ssubSUBSCREEN_VIEWS:SAPLV69A:7500/subSUB_FOREIGN_VIEW:ZOOM_PRCFIX_OVERVIEW:9002/cntlCC_PRCFIX1/shellcont/shell").modifyCell 0, "EXERCISERATE_DF34", Range("O2")
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\06/ssubSUBSCREEN_BODY:SAPLV69A:5201/subSUBSCREEN_PRICING:SAPLV69A:7201/ssubSUBSCREEN_VIEWS:SAPLV69A:7500/subSUB_FOREIGN_VIEW:ZOOM_PRCFIX_OVERVIEW:9002/cntlCC_PRCFIX1/shellcont/shell").modifyCell 1, "EXERCISERATE_DF34", Range("P2")
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\06/ssubSUBSCREEN_BODY:SAPLV69A:5201/subSUBSCREEN_PRICING:SAPLV69A:7201/ssubSUBSCREEN_VIEWS:SAPLV69A:7500/subSUB_FOREIGN_VIEW:ZOOM_PRCFIX_OVERVIEW:9002/cntlCC_PRCFIX1/shellcont/shell").modifyCell 2, "EXERCISERATE_DF34", Range("Q2")
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\06/ssubSUBSCREEN_BODY:SAPLV69A:5201/subSUBSCREEN_PRICING:SAPLV69A:7201/ssubSUBSCREEN_VIEWS:SAPLV69A:7500/subSUB_FOREIGN_VIEW:ZOOM_PRCFIX_OVERVIEW:9002/cntlCC_PRCFIX1/shellcont/shell").setCurrentCell 2, "EXERCISERATE_DF34"
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\06/ssubSUBSCREEN_BODY:SAPLV69A:5201/subSUBSCREEN_PRICING:SAPLV69A:7201/ssubSUBSCREEN_VIEWS:SAPLV69A:7500/subSUB_FOREIGN_VIEW:ZOOM_PRCFIX_OVERVIEW:9002/cntlCC_PRCFIX1/shellcont/shell").pressEnter
session.findById("wnd[0]/tbar[0]/btn[11]").press


Set xclwbk = Nothing
Set xclsht = Nothing
Set xclapp = Nothing


End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top