RodrigoFinguer
Board Regular
- Joined
- Jun 13, 2017
- Messages
- 75
Guys, I am struggling with this....
I am trying to check if there are attachments in PR for service, but I can only check if my macro click to open the attachment table. In some cases, when there are not attachments, the SAP crashes because the macro opened the table where wasn't able to open.
I need a solution to check if there are attachments in the clip and in "Services for object" button
I am trying to check if there are attachments in PR for service, but I can only check if my macro click to open the attachment table. In some cases, when there are not attachments, the SAP crashes because the macro opened the table where wasn't able to open.
Code:
Sub attachment()
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:00" & x & "/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3212/cntlGRIDCONTROL/shellcont/shell").currentCellColumn = ""
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:00" & x & "/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3212/cntlGRIDCONTROL/shellcont/shell").selectedRows = "0"
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:00" & x & "/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3212/cntlGRIDCONTROL/shellcont/shell").pressToolbarButton "&MEREQDMS"
On Error GoTo 1
'check if attachments are in the "clip" button in the PR, if there are attachments, go to 1
Set SAP_attach_ini = session.findById("wnd[1]/usr/txtMESSTXT1")
If SAP_attach_ini Is Nothing Then
1:
On Error GoTo -1
On Error GoTo 0
ThisWorkbook.Sheets("i1").Cells(Z + 1, 7).Value = 1
session.findById("wnd[1]/tbar[0]/btn[0]").press
GoTo 2
'if there are no attachments, close popup message and open attachment for services in the toolbox "Services for object" button
Else
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/titl/shellcont/shell").pressButton "%GOS_TOOLBOX"
'Here, when there are no attachments, SAP crashes because the following code open "attachment list" if there are or not attachments
session.findById("wnd[0]/shellcont/shell").pressButton "VIEW_ATTA"
On Error GoTo 3
'check if there are attachments
Set SAPattachs = session.findById("wnd[1]/usr/cntlGRID1/shellcont/shell")
I need a solution to check if there are attachments in the clip and in "Services for object" button