Run SAP with VBA Excel

Cesar PeRi

New Member
Joined
Jan 5, 2023
Messages
1
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello friends of MrExcel.com good evening, I request your help please, I can't figure out how I should do so that the data such as user, password, date from-to are editable (variables) and not fixed

Set objshell = CreateObject("WScript.Shell")
Set objapp = objshell.Exec("C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe")
Application.Wait Now + TimeValue("00:00:05")
AppActivate "SAP Logon 770" '(el nombre que te aparezca en la pestaña cuando lo abras)
Application.Wait Now + TimeValue("00:00:04")
Application.SendKeys "~", True '(la virgula significa Enter)
Application.Wait Now + TimeValue("00:00:02")
Application.SendKeys "pere***", True '(Usuario)
Application.Wait Now + TimeValue("00:00:02")
Application.SendKeys "{TAB}", True
Application.Wait Now + TimeValue("00:00:02")
Application.SendKeys "******", True '(Contraseña)
Application.Wait Now + TimeValue("00:00:02")
Application.SendKeys "~", True
Application.Wait Now + TimeValue("00:00:03")
Application.SendKeys "{F3}", True '(Regresa pantalla anterior)
Application.Wait Now + TimeValue("00:00:03")
Application.SendKeys "mb51", True '(Tx)
Application.Wait Now + TimeValue("00:00:03")
Application.SendKeys "~", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.SendKeys "2608", True '(Planta)
Application.SendKeys "~", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "101", True '(Movimiento)
Application.SendKeys "~", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "03.01.2023", True '(Fecha inicio)
Application.SendKeys "{TAB}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "03.01.2023", True '(Fecha fin)
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{tab}", True
Application.SendKeys "{tab}", True
Application.SendKeys "~", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
'Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DEL}", True
Application.SendKeys "{DEL}", True
Application.SendKeys "{DEL}", True
Application.SendKeys "{DEL}", True
Application.SendKeys "{DEL}", True
Application.SendKeys "{DEL}", True
Application.SendKeys "{DEL}", True
Application.SendKeys "{DEL}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "/CESAR REP", True '(Lay out)
Application.SendKeys "~", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{F8}", True

Thanks for your help
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hello friends of MrExcel.com good evening, I request your help please, I can't figure out how I should do so that the data such as user, password, date from-to are editable (variables) and not fixed

Set objshell = CreateObject("WScript.Shell")
Set objapp = objshell.Exec("C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe")
Application.Wait Now + TimeValue("00:00:05")
AppActivate "SAP Logon 770" '(el nombre que te aparezca en la pestaña cuando lo abras)
Application.Wait Now + TimeValue("00:00:04")
Application.SendKeys "~", True '(la virgula significa Enter)
Application.Wait Now + TimeValue("00:00:02")
Application.SendKeys "pere***", True '(Usuario)
Application.Wait Now + TimeValue("00:00:02")
Application.SendKeys "{TAB}", True
Application.Wait Now + TimeValue("00:00:02")
Application.SendKeys "******", True '(Contraseña)
Application.Wait Now + TimeValue("00:00:02")
Application.SendKeys "~", True
Application.Wait Now + TimeValue("00:00:03")
Application.SendKeys "{F3}", True '(Regresa pantalla anterior)
Application.Wait Now + TimeValue("00:00:03")
Application.SendKeys "mb51", True '(Tx)
Application.Wait Now + TimeValue("00:00:03")
Application.SendKeys "~", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.SendKeys "2608", True '(Planta)
Application.SendKeys "~", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "101", True '(Movimiento)
Application.SendKeys "~", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "03.01.2023", True '(Fecha inicio)
Application.SendKeys "{TAB}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "03.01.2023", True '(Fecha fin)
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{tab}", True
Application.SendKeys "{tab}", True
Application.SendKeys "~", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
'Application.SendKeys "{DOWN}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{DEL}", True
Application.SendKeys "{DEL}", True
Application.SendKeys "{DEL}", True
Application.SendKeys "{DEL}", True
Application.SendKeys "{DEL}", True
Application.SendKeys "{DEL}", True
Application.SendKeys "{DEL}", True
Application.SendKeys "{DEL}", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "/CESAR REP", True '(Lay out)
Application.SendKeys "~", True
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{F8}", True

Thanks for your help
I have used different approach, so you can choose cells in excel to input data , and then go with appActivate to switch between and copy from cell and paste to SAP it works quite smooth , hope that helps
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

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