VBA to check SAP Purchase Requisition attachments for Service

RodrigoFinguer

Board Regular
Joined
Jun 13, 2017
Messages
73
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
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

RodrigoFinguer

Board Regular
Joined
Jun 13, 2017
Messages
73
I need to check if "Attachment List" is enabled or not:




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

Watch MrExcel Video

Forum statistics

Threads
1,102,039
Messages
5,484,329
Members
407,436
Latest member
Szafranski

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top