cancel
Showing results for 
Search instead for 
Did you mean: 

SAPBEXreadWorkbook release 3.5 to 7.0

Former Member
0 Kudos

Hi everybody

I am using some VBA to open a template with diagramm and graphics in Excel and I fill it with results of a workbook. In 3.5 everything was running nicely. In 7.0 there are/were some troubles.

<b>Old code:</b>

Const WBID_TEMPLATE As String = "CQ00SA3O0OIMA70BN1HOPO6A7"

Dim sWbTemplate As String

...

sWbTemplate = Run("SAPBEX.XLA!SAPBEXreadWorkbook", WBID_TEMPLATE)

...

this code is not working under 7.0 anymore. So after reading through SDN I took away the SAPBEX.XLA which is public now and does not need to be called anymore. This worked without error message but it also did not give any value back. sWBTemplate is always empty.

I solved the problem by adding a code line and reading the name of the active Workbook in the variable and this even works. But I still don't understand why I don't get a value back right away. Can somebody explain this behaviour to me?

<b>new code:</b>

Const WBID_TEMPLATE As String = "CQ00SA3O0OIMA70BN1HOPO6A7"

Dim sWbTemplate As String

...

sWbTemplate = Run("SAPBEXreadWorkbook", WBID_TEMPLATE)

sWBTemplate = ActiveWorkbook.Name

...

Any ideas, comments?

thanks!

christophe

Accepted Solutions (1)

Accepted Solutions (1)

klaus_buchner2
Explorer
0 Kudos

Do you still use the BEx-Analyzer for BW 3.X?

I guess you already use the new (BI 7.0) BEx Analyzer

SAP changed the Name of the BEx Excel Add-In. The new name is BExAnalyzer.xla

So the code to open a Workbook in BI 7.0 is like this:

a = Run("BExAnalyzer.xla!SetStart")

b = Run("BExAnalyzer.xla!runWorkbook", wbid)

the SAPBEX* Commands still seems work, but if you debug you'll find out that they will (should) post an error in the trace. Unfortunatelly you don't get a real error message!

If somebody has a hint where to find further documentation about the new BExAnalyzer.xla commands, please forward it to me!

Regards

Klaus

Answers (2)

Answers (2)

Former Member
0 Kudos

thanks for your hints Pete! sorry that there was no earlyer answer from me, but the testsystem has been rebuilt.

I see some things a bit clearer now about Add-Ins in Excel. But still don't understand the bahaviour of the code.

You were right, the name of the Add-In has changed to BExAnalyzer.XLA. And there is a routine named SAPBEXreadWorkbook, but I can not find a reference in the Project Explorere View. What does a reference look like? But as the call code you proposed is not working I guess there is really no reference.

code: call BExAnalyzer.sapbexreadworkbook(string). returns a runtime error that variable bexanalyzer is not known....

Does anybody know why the run("SAPBEXreadWorkbook", string) does not give a value back anymore under 7.0??

Thanks!

christophe

Former Member
0 Kudos

Hi Christophe,

What does a reference look like?

1. In Project Explorer view, you would see under the VBAProject for you workbook a "folder" for References, similar to the folder for Microsoft Excel Objects and Modules.

2. When you type "BExAnalyzer.", as soon as you type the "." As soon as you type the first ".", the list of available functions should show up and as you type SAPBEXreadWorkbook, the VB Editor should auto-find the correct subroutine.

If either of these two things is NOT happening, then you do not have a reference. This would explain why you get the error message "variable bexanalyzer is not known....". In other words, since "bexanalyzer" is not defined within your VBA project, it is an undefined variable.

Although you have no reference, that should be OK. You should be able to use:

sWbTemplate = Run("BExAnalyzer.xla!SAPBEXreadWorkbook", WBID_TEMPLATE)

Have you tried that?

- Pete

Former Member
0 Kudos

Hi Pete

yes I did try that and the result is the same. I do not get a value back in sWbTemplate....

so I still neet to get the name like this: sWBTemplate = ActiveWorkbook.Name

What I am still wondering is what SAP changed in the SAPBEXreadWorkbook. So if anybody feels familiar with the coding in there then let me know, because I can only watch the code under BW7.0, on 3.5 it is password protected...

thanks pete for your help and ideas! I understand a bit more about the way VBA works!!

regards

christophe

Former Member
0 Kudos

Hi Christophe,

Hmmm ... unfortunately, I do not have BW7.0 to play with; but, from a pure Excel/VBA point of view, I can tell you what does not sound right to me, and give a couple of suggestions to try.

Let me start by explaining the Excel/VBA "Run" command. This is not part of Visual Basic, it is part of Excel. The default is to always give the name of the workbook (or Add-In) containing the subroutine or function being called. In other words, even if "SAPBEX.XLA!" is not required, it should still work. Unless, of course, the name of the Add-In has changed. You can check this in the VB Editor, Project Explorer view. Is there an Add-In loaded? What is its name? (In parenthesis). If it is not "SAPBEX.XLA", then give the correct file name.

Next, does this Add-In contain a publicly available routine named SAPBEXreadWorkbook? The way to find out is to select the Add-In (click only once; if you get a dialog asking for a password, close the dialog). With the Add-In selected, launch the ObjectBrowser (press F2). Go to the second box from top, left (the search window) and enter readworkbook, then click the Find icon. This should bring up the path to the subroutine you are looking for (if it exists).

When you say that SAPBEX.XLA is "public now", what you mean is that there is a reference to SAPBEX.XLA in the Excel workbook's VBProject. You should be able to see this reference explicitly attached to the Excel workbook (in the Project Explorer view). Is it there?

If so, you can write the function call as follows:

Call SAPBEX.SAPBEXreadWorkbook, stringForWorkbookID

As soon as you type the first ".", the list of available functions should show up and as you type SAPBEXreadWorkbook, the VB Editor should auto-find the correct subroutine. Is this happening?

Hopefully this gives you something to look at while we wait for someone who does have BW7.0 experience to give us further advice.

- Pete