plwhittington
Board Regular
- Joined
- May 10, 2007
- Messages
- 132
I've written VBA code in Excel to (1)run some t-codes in SAP, (2)capture screenshots, and (3)paste in MS Word.
Everything works, but I have to hardcode the name of the SAP screen when it's time to switch focus from Excel to SAP in order to do the screen capture. I can hardcode every SAP Screen to capture in the code, but that is very tedious. I would like for the program to be able to get SAP to the correct screen, identify the screen name it is on, then use AppActivate to set the focus on that screen for screen capture.
Currently, I call the following code in a subroutine, which executes the SM35 T-code in SAP:
session.findbyId("wnd[0]").maximize
session.findbyId("wnd[0]/tbar[0]/okcd").Text = "/nsm35"
session.findbyId("wnd[0]").sendVKey 0
session.findbyId("wnd[0]/usr/subD1000_HEADER:SAPMSBDC_CC:1005/txtD0100-MAPN").Text = "FI_TRA*"
session.findbyId("wnd[0]/usr/subD1000_HEADER:SAPMSBDC_CC:1005/ctxtD0100-VON").Text = "11/10/2014"
session.findbyId("wnd[0]/usr/subD1000_HEADER:SAPMSBDC_CC:1005/ctxtD0100-BIS").Text = "11/10/2014"
session.findbyId("wnd[0]/usr/subD1000_HEADER:SAPMSBDC_CC:1005/txtD0100-CREATOR").Text = "*"
session.findbyId("wnd[0]/usr/subD1000_HEADER:SAPMSBDC_CC:1005/ctxtD0100-BIS").SetFocus
session.findbyId("wnd[0]/usr/subD1000_HEADER:SAPMSBDC_CC:1005/ctxtD0100-BIS").caretPosition = 10
session.findbyId("wnd[0]").sendVKey 0
once the code runs, the correct SAP screen is present, but not active. I can activate it by using the following code:
AppActivate "Batch Session: Input Overview"
"Batch Session: Input Overview" is the name of the Task in Windows Task Manager (not the process name). I need to be able to use a variable in place of it so I don't have to look up and hard code every screen in SAP.
Thanks for any help.
Everything works, but I have to hardcode the name of the SAP screen when it's time to switch focus from Excel to SAP in order to do the screen capture. I can hardcode every SAP Screen to capture in the code, but that is very tedious. I would like for the program to be able to get SAP to the correct screen, identify the screen name it is on, then use AppActivate to set the focus on that screen for screen capture.
Currently, I call the following code in a subroutine, which executes the SM35 T-code in SAP:
session.findbyId("wnd[0]").maximize
session.findbyId("wnd[0]/tbar[0]/okcd").Text = "/nsm35"
session.findbyId("wnd[0]").sendVKey 0
session.findbyId("wnd[0]/usr/subD1000_HEADER:SAPMSBDC_CC:1005/txtD0100-MAPN").Text = "FI_TRA*"
session.findbyId("wnd[0]/usr/subD1000_HEADER:SAPMSBDC_CC:1005/ctxtD0100-VON").Text = "11/10/2014"
session.findbyId("wnd[0]/usr/subD1000_HEADER:SAPMSBDC_CC:1005/ctxtD0100-BIS").Text = "11/10/2014"
session.findbyId("wnd[0]/usr/subD1000_HEADER:SAPMSBDC_CC:1005/txtD0100-CREATOR").Text = "*"
session.findbyId("wnd[0]/usr/subD1000_HEADER:SAPMSBDC_CC:1005/ctxtD0100-BIS").SetFocus
session.findbyId("wnd[0]/usr/subD1000_HEADER:SAPMSBDC_CC:1005/ctxtD0100-BIS").caretPosition = 10
session.findbyId("wnd[0]").sendVKey 0
once the code runs, the correct SAP screen is present, but not active. I can activate it by using the following code:
AppActivate "Batch Session: Input Overview"
"Batch Session: Input Overview" is the name of the Task in Windows Task Manager (not the process name). I need to be able to use a variable in place of it so I don't have to look up and hard code every screen in SAP.
Thanks for any help.