Skip to Content
0
Sep 03, 2018 at 04:25 PM

run VBS macro on double click of cell

1017 Views

Hello,

I have a sheet called "PO orders".

I have values (PO orders) in column A of that sheet (A7:A1000)

What I'd like to have is when I double click on a cell:

Copy clicked cell

Go to transaction Me22N and fill out the PO order.

So the user can change the delivery date of Po orders

Thx

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)


If Not Intersect(Target, Range("A:A")) Is Nothing Then
'MsgBox "Nice Work!" 'place your macro/code here
 Selection.Copy
       Set SapGuiAuto = GetObject("SAPGUI")
 
   Set Applicationa = SapGuiAuto.GetScriptingEngine


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 Application, "on"
End If


session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nme22n"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[17]").press


session.findById("wnd[1]/usr/subSUB0:SAPLMEGUI:0003/ctxtMEPO_SELECT-EBELN").caretPosition = 10
session.findById("wnd[1]/tbar[0]/btn[0]").press
End If


End Sub