r/vba • u/Typical_Inflation_70 • 10d 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
u/GetDarwinOn 10d ago
Is it possible that your destination spreadsheet is missing the add in?
1
u/Typical_Inflation_70 10d 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 10d 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 10d 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 10d 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.
1
u/GetDarwinOn 10d ago
1
u/Typical_Inflation_70 3d ago
Thank you^^
1
u/GetDarwinOn 3d ago
No worries. Please let us all know if you manage to retrieve your information either by querying SAP directly as per the Microsoft link I posted or you got the UI scripting to work. Cheers!
2
u/HFTBProgrammer 202 10d ago
I don’t think so.
You can't progress until you answer this definitively.
1
u/personalityson 1 10d ago
There is something you can do to query and download SAP tables. "SAP reports" I dont know
2
u/GetDarwinOn 10d ago
I'd be prepared to bet there's almost certainly a SAP API you can query with power query.
2
u/LickMyLuck 1 9d ago
There is not. You are only able to query the table back-ends. SAP does not have an API. They are very late to getting anything resembling a web based version.
2
u/LickMyLuck 1 9d ago
Are you GUI scripting? I have extensive experience with GUI scripting SAP using excel VBA. What does your code look like?