Hi all,
Although i only recently joined as a member, this forum has been invaluable and often popped up when searching the internet for solutions to problems i have had in the past.
Thankyou to the community for all your hard work.
I have been working on macro's now between excel and SAP for a while, automated scripting between the two to build databases automatically but I am still a beginner and have been learning as I go.
My current problem is that I want to use the data in a cell in excel to fill a box in SAP. I have worked out how to do it the other way around e.g.
Cells(9, 15).Value = session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB08/ssubSUB_GROUP_10:SAPLIQS0:7218/ctxtRMIPM-PLNNR").Text
Anyone any ideas on how to do it the other way around.
PS
Sheets("XXX").Activate
###### Second Question
The code which enables the connection between SAP and Excel has to be repeated every time you swap between the two - I have tried putting this code as a sub on its own, and then calling it within another sub (example below), but it doesn't work and debugs in the fashion that it would if you tried to manipulate SAP without the code being there (A problem encountered in the early days of my current work!).
Can anyone suggest a way of globally declaring it? and then referencing it multiple times throughout the module without having to repeat it? As I said im not a programmer but an analyst so I appreciate this might be a easy task.
Sub Enable_SAP
On Error Resume Next
'######## Get SAP GUI scripting object and test connection
Set SapGuiAuto = GetObject("SAPGUI")
If SapGuiAuto Is Nothing Then
MsgBox ("No Connection to SAP")
Exit Sub
End If
'######## Get the currently running SAP GUI and Allow scripts
Set SAPApp = SapGuiAuto.GetScriptingEngine
Set SAPCon = SAPApp.Children(0) '<---- First session to binded SAP server (can have multiple sessions active)
If SAPCon Is Nothing Then
MsgBox ("No Open Sessions")
Exit Sub
End If
Etc ……
Sub X
Call Enable_SAP
session.findById("wnd[0]").resizeWorkingPane 201, 30, False <------ Debug Error Here as if module has not been called
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nziw39"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/chkDY_MAB").Selected = True
session.findById("wnd[0]/usr/chkDY_HIS").Selected = True
….
Thanks in advance
Although i only recently joined as a member, this forum has been invaluable and often popped up when searching the internet for solutions to problems i have had in the past.
Thankyou to the community for all your hard work.
I have been working on macro's now between excel and SAP for a while, automated scripting between the two to build databases automatically but I am still a beginner and have been learning as I go.
My current problem is that I want to use the data in a cell in excel to fill a box in SAP. I have worked out how to do it the other way around e.g.
Cells(9, 15).Value = session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB08/ssubSUB_GROUP_10:SAPLIQS0:7218/ctxtRMIPM-PLNNR").Text
Anyone any ideas on how to do it the other way around.
PS
session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB08/ssubSUB_GROUP_10:SAPLIQS0:7218/ctxtRMIPM-PLNNR").Text =
Windows("XXX.xlsm").ActivateCells(9, 15).Value
Doesn't work because I guess I am not activating the workbook and worksheet, IE:
Doesn't work because I guess I am not activating the workbook and worksheet, IE:
Sheets("XXX").Activate
###### Second Question
The code which enables the connection between SAP and Excel has to be repeated every time you swap between the two - I have tried putting this code as a sub on its own, and then calling it within another sub (example below), but it doesn't work and debugs in the fashion that it would if you tried to manipulate SAP without the code being there (A problem encountered in the early days of my current work!).
Can anyone suggest a way of globally declaring it? and then referencing it multiple times throughout the module without having to repeat it? As I said im not a programmer but an analyst so I appreciate this might be a easy task.
Sub Enable_SAP
On Error Resume Next
'######## Get SAP GUI scripting object and test connection
Set SapGuiAuto = GetObject("SAPGUI")
If SapGuiAuto Is Nothing Then
MsgBox ("No Connection to SAP")
Exit Sub
End If
'######## Get the currently running SAP GUI and Allow scripts
Set SAPApp = SapGuiAuto.GetScriptingEngine
Set SAPCon = SAPApp.Children(0) '<---- First session to binded SAP server (can have multiple sessions active)
If SAPCon Is Nothing Then
MsgBox ("No Open Sessions")
Exit Sub
End If
Etc ……
Sub X
Call Enable_SAP
session.findById("wnd[0]").resizeWorkingPane 201, 30, False <------ Debug Error Here as if module has not been called
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nziw39"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/chkDY_MAB").Selected = True
session.findById("wnd[0]/usr/chkDY_HIS").Selected = True
….
Thanks in advance