Execute VB Script/ SAP Script from Excel

ramkrishna1111

New Member
Joined
Dec 10, 2014
Messages
3
Hello,I would like to execute VB Script/ SAP script from excel. I've prepared sub in VBA using script but I am unable to assign this macro or unable to call it.My code is in parts, 1st one is VB script to pull data from SAP & in 2nd part I've VBA code to perform excel operations.Due to restrictions I'm unable to share my code but someone could help me to guide on how to execute VB Script/ SAP script from Excel VBA, that would be great..!!Thanks in advance :)
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi,

It is a while since I did this and I no longer have any access to SAP. However, from memory:

I started off with a VBScript that I had recorded in SAP.
I then deleted all the superfluous lines. For example, it always remembered the position of the cursor and usually that was not required so I removed those.
Then I inserted blank lines and added comments so that I could work out what it was doing.
Then I removed the first part that connected to SAP and turned the rest into a subroutine. The parameters for the transaction would be added and the constants turned into variables where necessary.

Then I had a master "boiler plate" VBScript that had the connection details for SAP Session 1. It also had the code to control Excel. It would fire up Excel and load a data file in the same folder.
This boiler plate code would be amanded to read in the right columns from the Excel workbook.
Then the code from the recording with the changes would be pasted in.
After that the script could be started, this would connect to SAP and load the workbook. It would then read the rows of the workbook until it found a blank line and send the data to SAP row by row. I did some with two routines to call parts of transactions separately.

If I had had some time to experiment I am fairly sure that I could have managed without the modified boiler plate script and driven everything from Excel but I retired before that happened!
Connecting could be tricky. I used to close all SAP sessions regardless of client or box then start again from the SAPGUI. This would ensure that the first session of the first connection would be available. It also stopped me from running test transactions in production by accident - never a popular move!

I hope this helps.
 
Upvote 0

Forum statistics

Threads
1,214,801
Messages
6,121,644
Members
449,045
Latest member
Marcus05

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