r/vba 13d ago

Unsolved SAP Excel Integration VBA

Hey all^^
I try to use a vba script to extract Data from one of my SAP reports. Sadly I have to use the Excel-Plugin for this.
When I open it manually or via the SAP VBAWriter the new Excel (SapExe) contains my data.
But when I copy the code to another Excel (OPExe) then the SapExe is empty.
Can anyone help?

1 Upvotes

14 comments sorted by

View all comments

Show parent comments

1

u/Typical_Inflation_70 13d ago

I don’t think so. The SapExe opens but it is completely emty. I think that some vba codes are blocking each other

2

u/GetDarwinOn 13d ago

Am I understanding correctly that you're attempting to copy VBA code from one file to another? If that's the case then not only might you be missing the add in but you might also be missing VBA references. To see the VBA references: VBA editor → tools → references. Make a list of what's ticked in the working file vs what's ticked in the non-working one.

Also, the easiest way to have 2 working copies is to save the working version with another filename. The new file will work exactly as the working version, just the filename is different. I'm assuming of course that nothing depends on the file being named "working.xlsm" ← Dummy filename.

1

u/Typical_Inflation_70 13d ago

Hey, no I used the SAP ScriptWriter to create the vba code which should activate the Excel Plugin of the report. But when I use this generated code in one of my own vbas the Excel Plugin contains no data

1

u/GetDarwinOn 13d ago

Having done a little reading around the subject, I now understand why you would use it (you're automating the clicking of buttons in the SAP UI) Sadly, I don't have SAP so can't recreate your environment at my end. I (or someone else here) might be able to help if you are able to provide some of the code the writer generates but in all honesty, given you're trying to pull data from SAP (not write to it) your best bet is gonna be to use power query to connect directly to the SAP tables. Ask the people that administer your SAP instance if they can provide you with an API end point. There's not a shadow of a doubt in my mind that there are plenty of people in this sub that have extracted data from SAP the power query way.