Private Sub CommandButton1_Click()
MsgBox ("Please double click on the order you wish to alter the routing for and press ok")
'setting the connection with sap:
Dim App, Connection, session As Object
Dim StartRange As String
Dim EndRange As String
Set SapGuiAuto = GetObject("SAPGUI")
Set App = SapGuiAuto.GetScriptingEngine
Set Connection = App.Children(0)
Set session = Connection.Children(0)
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[1]/btn[25]").presssession.findById("wnd[0]/tbar[1]/btn[8]").presssession.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\13").Select
session.findById("wnd [0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\13/ssubSUBSCREEN_BODY:SAPMV50A:2126/ssubCUSTOMER_SCREEN:SAPLZGWM_XPS_CUSTOM_TAB:9000/btnRATE_SHOP").presssession.findById("wnd[1]/usr/cmbGV_WERKS").Key = "3110"
session.findById("wnd[1]/usr/cmbGV_GROUP").SetFocus
session.findById("wnd[1]/usr/cmbGV_GROUP").Key = "DOM"
session.findById("wnd[1]/tbar[0]/btn[13]").press
session.findById("wnd[1]/usr/cmbGV_GROUP").SetFocus
Selection.Offset(0, 12).Select
EndRange = ActiveCell.Address
session.findById("wnd[2]/tbar[0]/btn[13]").press
session.findById("wnd[1]/tbar[0]/btn[14]").press
session.findById("wnd[0]/tbar[0]/btn[11]").press
End Sub