Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Method to check any excel file is open or not on presentation server or pc

Former Member
0 Kudos

I am downloading the data of ALV to Excel using OLE methods, but before downloading how can i check that any excel file is already open on PC or not?

We have options to check whether the excel file is already open or not with the known name but how we can check for the opened file without knowing its name or path?

10 REPLIES 10

nikolayevstigneev
Contributor
0 Kudos

Hi!

Maybe checking that Excel is running as a process will be sufficient for you?

Then you can google the macro easily like for example this one. Besides that, another idea is suggested there - getting a list of open windows. Please, have a look.

0 Kudos

In my report i want add this functionality that if any excel file is open then throw a message, basically we have methods to check that with any particular name file exists or not but what are the methods by which we can find out that any excel file is open on pc?

0 Kudos

I am talking about the methods or function module within abap, or the piece of code that i can write in my report.

0 Kudos

I'm not sure whether you can do much with "pure" ABAP in this case. What I meant to say is if you get a working VBA code, you can embed it in your report either rewriting it with the help of OLE or (just as an idea) by uploading a file with macro to user PC, opening it with Excel and running macro. The level of solution's madness may vary

You haven't answered whether it is enough for you to get the process list on user PC and check for Excel running. It can save your time.

0 Kudos

I can go for another functionality also but that has to work with abap code.

In OLE we have any functionality?

0 Kudos

Okay, this time I'll ask my question from the early beginning:

Will it be enough for you to get the process list on user PC and check for Excel running?

If so, you can make an extremely quick solution running smth like tasklist on user PC

You can do plenty of stuff with the help of OLE, search for examples, SCN has a lot of posts like this one. But better leave it as a last resort.

0 Kudos

Hi Nikolay,

I worked out an approach by executing TASKLIST on the workstation and redirecting the output to a text file.  Then that text file can be uploaded by your ABAP program and you can search to see if any of the tasks are "excel.exe".

The only problem is that I can't see how to redirect the output from the TASKLIST command to a file just using the CL_GUI_FRONTEND_SERVICES=>EXECUTE method.  It doesn't seem to handle the syntax like "TASKLIST > h:\temp.txt".  So to make it work I had to create a batch file on the workstation that contains that command.  I made a file named h:\get_tasklist.bat, which is a text file with single line "TASKLIST > h:\temp.txt".  Then I execute that batch script from ABAP program, upload h:\temp.txt and see what's there.  So this all works fine assuming that you can install this batch file on the workstations.  I guess if necessary your ABAP program could create it in a temp directory using GUI_DOWNLOAD.

Jim

0 Kudos

Hi Jim,

I believe you can run tasklist with the help of external command (SM69) without uploading batches to presentation server.

As for me, syntax like

tasklist /fo CSV /nh > 123.csv

worked fine. All you need is to get sap gui workdir and add it to filename.

Then you can upload it as csv and parse as you like.

0 Kudos

Hi Nikolay,

But SM69 runs commands on the application server; the OP needs to know whether Excel is running on the presentation server

Former Member
0 Kudos

Hi Yash

try to upload and download the file in the presentation.

If file is already opened you receive an exception.

I used cl_gui_frontend_serivces methods (gui_upload and gui_download)

Regards