cancel
Showing results for 
Search instead for 
Did you mean: 

Getting range of query result in 2004s

0 Kudos

Hi,

I'm trying to determine range of a result area in a 2004s query using the following code :

Dim myrange As Range

Set myrange = Run("BEXAnalyzer.xla!SAPBEXgetResultRangeByID", "ZSKMILESTONESTEST")

I have also tried this using the technical ID of the query as in RZSCOMPDIR.

This causes a VB error and stops inside the SAPBEXgetResultRangeByID function and says "Object Variable or with block not set" on this line :

Set SAPBEXgetResultRangeByID = pAddin.SAPBEXgetResultRangeByID(ActiveWorkbook.Name, queryID, charName)

Can anyone help ?

Cheers

Sue

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Sue

if still interested use the old fashioned SAP Bex Exit.

In Workbook Property tell the workbook to use a macro and instead of calling CallBack run your own first using the sub below than callback by SAP to format the headers...

Best regards

Joerg

Sub SAPBEXonRefresh(queryID As String, resultArea As Range)

End Sub

andreas_appelt
Explorer
0 Kudos

Hi Sue,

did you solve this problem? And if yes, how?

Thanks for the info.

Andreas

Former Member
0 Kudos

Hi Sue,

I know nothing about 2004s. But, I know something about SAPBEXgetResultRangeByID.

The function's definition (from Object Browser) is:

Function SAPBEXgetResultRangeByID(ByVal queryID As String, Optional ByVal charName As String) As Range

Here are two examples that work for me ...

'This example locates query result Area using local query ID

Sub testResultRangeByID1()

Dim resultArea As Range, queryID As String

queryID = "SAPBEXq0001"

Set resultArea = Run("SAPBEX.xla!SAPBEXgetResultRangeByID", queryID)

Application.Goto reference:=resultArea

End Sub

'This example locates a characteristic's filter cell

'using local query ID and technical name of characteristic

Sub testResultRangeByID2()

Dim resultArea As Range, queryID As String

queryID = "SAPBEXq0001"

Set resultArea = Run("SAPBEX.xla!SAPBEXgetResultRangeByID", queryID, "0SHIP_TO")

Application.Goto reference:=resultArea

End Sub

Hope this helps.

- Pete