Skip to Content
0
Jul 26, 2019 at 06:41 AM

SAP BW VBA/VBS coding

115 Views

Dear reader,

I am facing a difficult rather "Grey" challenge.

The problem is that we don't know which causes the problem.

Lets get started..

The first thing the VBS script will do is open my excel, enable Analysis for Excel (see code #1 below) and refresh my data (see code #2 below).

CODE #1
Private Sub Workbook_Open()
Dim lResult As Long
    Dim addin As COMAddIn
    For Each addin In Application.COMAddIns
        If addin.progID = "SapExcelAddIn" Then
            If addin.Connect = False Then
                addin.Connect = True
            ElseIf addin.Connect = True Then
                addin.Connect = False
                addin.Connect = True
            End If
            
        End If
    Next
End Sub




CODE #2
Sub Refresh_the_Data()
Dim lResult As Long
lResult = Application.Run("SAPLogon", "DS_1", "500", "USERNAME", "PASSWORD")
lResult = Application.Run("SAPExecuteCommand", "RefreshData", "DS_1")
End Sub

When the Windows Task Manager starts to open the excel, it refreshes automatically and opens Analysis for Excel.

(This has been tested on a x64 version of windows and worked)

When we do that same thing manually, SAP gives an error that it cant use the SAPLogon within Business Analysis. (it just doesn't start Analysis for Excel)

In the past we used to do this with an x32 version of Windows on the previous computer and it all worked perfectly fine.

Since we are using a new laptop (x64) it works when run automatically, but not manually.

Does anyone have some experience with this and can tell me what to do?