Showing results for 
Search instead for 
Did you mean: 

SAP GUI 7.4 Patch 12 - Disallow Excel Auto Open

Active Contributor

Restored question from @tybtech aka Will Hankins, 2019/01/22

Hello all,

I have seen this question asked a few times, but I can't find an answer that I've been able to use. The issue is simple. When exporting data from SAP GUI as spreadsheet, a new instance of Excel is automatically opened with the freshly exported data. How can I stop this? I am aware of workarounds such as exporting as a local file, but sometimes these don't format correctly.

I've tried changing some settings in Excel but nothing works. Any advice?



Accepted Solutions (1)

Accepted Solutions (1)

I encountered the same problem when I tried to automatically export and save as excel file for 1000 tables. After exporting a table to excel file, SAP automatically opens the downloaded file in another Excel Instance. I could not find any settings in SAP to turn off the auto-open so I have been using this code to quit other instances of Excel leaving the only instance of Excel in which my macro is running:

Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Sub closeOtherExcelInstances()
    Dim oServ As Object
    Dim cProc As Variant
    Dim oProc As Object
    Dim currentProcId
    currentProcId = GetCurrentProcessId
    Set oServ = GetObject("winmgmts:")
    Set cProc = oServ.ExecQuery("Select * from Win32_Process where NAME = 'EXCEL.EXE'")
    For Each oProc In cProc
        If oProc.ProcessId <> currentProcId Then
            Debug.Print oProc.Name, oProc.ProcessId
            errReturnCode = oProc.Terminate()
        End If
End Sub<br>

Update 08.04.2019

As I dug deeper to find acceptable solution for this matter. Something likes this also worth trying:

Sub close_excel_instance_sap()

    ' Variable to store other excel instance'
    Dim xlApp As Object

    ' some codes to export to excel from sap'
    ' Wait for other excel instance opened by SAP to appear'
    Application.Wait Now + TimeSerial(0, 0, 5)
    ' because after exporting to excel file, sap will open this exported excel file with another instance of Excel'
    ' so we need to close that instance'
    ' this code will give us access to other instance of Excel'
    ' It only works if you enter the fullpath of the exported excel file. Just the filename of the workbook will not work'
    ' do something with the exported workbook'
    ' close the exported workbook'
    xlApp.Workbooks(1).Close False
    ' close the excel instance'
End Sub
0 Kudos

Hello, it is works for me. Thank you for share.

Answers (4)

Answers (4)

I have SAP 7.50 now. I also looked at the note. Any other suggestions for stopping excel from automatically opening when exporting data?



Hello Will,

Can you review 159499 - Problems in the context of SAP Desktop Office Integration

Since 7.40 is not supported anymore, consider 7.50 Gui.

Please be aware that 7.60 is expected to be released next month. and support for 7.50 will end soon.

Note 66971 - Supported SAP GUI platforms

0 Kudos


This is a great solution! I needed something like this in order to be able to delete the file after sending it per email. I still get a weird "sorry we couldn't find the workbook xxx" popup but the process goes through beautifully.

Regarding the last question, I personally used xlApp.Workbooks(xlApp.Workbooks.count).Close

because it is always the last workbook that has to be closed and this method works well

Best regards,


0 Kudos

Hi , ducthanhnguyen

can you help me figure out the problem , i use your last code , to close exported excel sheet , but the code close all open excel sheets

sub exit ()

Dim xlApp As Object

Application.Wait (Now + TimeSerial(0, 0, 10))

Set xlApp = GetObject("D:\SAP scripting\COGS , Inv. Reconcile\COGS.xlsx").Application


end sub

'COGS is exported sheet and this what i need to close it