Skip to Content
0

SAP Log Issue while running VB script in Excel 07

Jul 15, 2017 at 05:30 PM

33

avatar image

Hi All,

1) I am running the VB script to log on SAP of my company SID. I gave the SID and instance number correctly and I am getting the below issue.

Where as I am able to open the same through normal Log on successfully.

Could anyone please help on this ?

  '-Begin-----------------------------------------------------------------
  '-Directives----------------------------------------------------------
    Option Explicit
  '-Variables-----------------------------------------------------------
    Dim WSHShell, SAPGUIPath, SID, InstanceNo, WinTitle
  '-Main----------------------------------------------------------------
Sub shell()


Set WSHShell = CreateObject("WScript.Shell")
   If IsObject(WSHShell) Then
      '-Set the path to the SAP GUI directory---------------------------
        SAPGUIPath = "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\"
      '-Set the SAP system ID-------------------------------------------
        SID = "UPD"
      '-Set the instance number of the SAP system-----------------------
        InstanceNo = "45"
      '-Starts the SAP GUI----------------------------------------------
        WSHShell.Exec SAPGUIPath & "sapgui.exe " & SID & " " & _
        InstanceNo
      '-Set the title of the SAP GUI window here------------------------
        WinTitle = "SAP"
     
      Set WSHShell = Nothing
    End If
    MsgBox "Here now your script..."


'-End-------------------------------------------------------------------


End Sub

2) And when I use the below code in above ,it throw error as Variable not found.

So I removed WScript and ran , and got the above issue in SAP Logon , though the script run successfully

Set WSHShell = WScript.CreateObject("WScript.Shell")<br>

Can anyone please help on the issue?

Thanks,
Sumanth

log-on-error.jpg (25.8 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers