Skip to Content

VB script to call SAP and add the result to excel

Oct 04, 2017 at 10:45 AM


avatar image
Former Member

Hi Guys,

I need help with vbscript. I am trying to create a code to open SAP and if it opens send the report to an excel sheet. I was able to do this with a ping server program but i want to do the same with SAP.

My current command list

Set Fso = CreateObject("Scripting.FileSystemObject")

Set InputFile = fso.OpenTextFile("Server.Txt")

'# Loop thru the text file till the end

Do While Not (InputFile.atEndOfStream)

HostName = InputFile.ReadLine

'# Create shell object for Pinging the host machines

Dim SAPGUIPath, server, InstanceNo, WinTitle

Set WshShell = WScript.CreateObject("WScript.Shell")

SAPGUIPath = "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\"

WSHShell.Exec SAPGUIPath & "sapgui.exe" & " " & HostName

objExcel.Cells(intRow, 1).Value = HostName

Select Case Ping

Case 0 objExcel.Cells(intRow, 2).Value = "Up"

Case 1 objExcel.Cells(intRow, 2).Value = "Down"

Best Regards,

Ishaan Baliwada

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers