VBA to check SAP Purchase Requisition attachments for Service

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.

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
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
I need to check if "Attachment List" is enabled or not:


2_158403.jpg


I have tried all I know but nothing so far worked...
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top