cancel
Showing results for 
Search instead for 
Did you mean: 

VBA Code - Automation

Jordan2
Discoverer
0 Kudos

Hi All,

How to insert an IF function into SAP VBA Code so that IF a pop up comes up "Data has been changed:", "Do you want to save the changes?" Yes, No or Cancel and I want to Press Yes and enter to continue but I can't seem to figure this out

 

TIA.

Jordan2
Discoverer
0 Kudos
Can I get some help for this please?

Accepted Solutions (1)

Accepted Solutions (1)

Jordan2
Discoverer
0 Kudos

Solved it with an extra few lines of code to auto save before it requests to save.

session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[0]").sendVKey 0

Answers (1)

Answers (1)

MKreitlein
Active Contributor
0 Kudos

Hello @Jordan2 

Maybe I don't understand your question right... but have you already tried google?

E.g: https://www.wallstreetmojo.com/vba-message-box-yes-no/

In your case you need to use "vbYesNoCancel"

BR, Martin

Jordan2
Discoverer
0 Kudos

Hi,

Yes I've tried to google loads but nobody seems to have a similar issue across most forums I've checked and searched.

My code below from when it goes into SAP below:

This is when a that pop up I've just attached to my original post comes up and it just completely bugs out as it doesn't always come up when I run the full code.

session.StartTransaction "DE9"
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "ZVP1A"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTABSTR/tabpVOR").Select
session.findById("wnd[0]/tbar[1]/btn[31]").press
session.findById("wnd[1]/usr/ctxtDY_PATH").Text = "C:\folder\setup\"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").Text = "Preallocation.txt"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 17
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/tabsTABSTR/tabpBAS").Select
session.findById("wnd[0]/tbar[1]/btn[31]").press
session.findById("wnd[1]/usr/ctxtDY_PATH").Text = "C:\folder\setup\"