Skip to Content
avatar image
Former Member

VB script to call SAP and add the result to excel

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers