Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Refresh a workbook via VBA

Hi all,

I have a workbook with a query inside and so far, users have to download this workbook, connect to SAP, and then refresh the query, changing the month. It's a simple sales report on a monthly basis.

My idea is to create a vba macro, so the users can pick-up the month from a combo-box and then click on "Refresh" and the query is automatically updated.

We were using Bex3 for those reports but now we have to migrate to Bex7 mandatory and as far as I understood, once you migrate the report to Bex7 this macro doesn't work anymore.

What I did so far is the connection string (yeah, so easy, I know...) and I need a guideline with function should I use to automatically refresh the query

Dim ObjBAPIControl As Object

Dim Sapconnection As Object

Set ObjBAPIControl = CreateObject("SAP.Functions")

Set Sapconnection = ObjBAPIControl.Connection

Sapconnection.Logon

If Sapconnection.Logon(0, True) <> True Then

MsgBox "CANNOT Log on to SAP"

End If

Thanks a lot for your help!

Martin

Former Member
Not what you were looking for? Ask a question