If a file is open get file to front [closed]
I get the following error when trying to open a workbook file.
The process cannot access the file '.. File.xls' because it is being used by another process
.
Instead of opening the file again, if the file is already open, how do I bring that workbook forward.
Copied from OP's comment:
Excel App is on front. The thing is, I opened a WorkBook programmatically, came to front. Now I did some work on old workbooks, clicked the button again to open the Workbook which is already open. Now since its open, gave me exception. So instead of that I want that old sheet to come front.
This is a two step solution
- You have to first find the process that is currently using the file
- Then, once you have the ProcessId, you have to bring it to the front using the Win32 API
If you are using excel-interop, then all you need to do is set visible to true for your instance of the excel application. For example
excelApp.Visible = true;
even if if the value is already true, this will bring it to the front.
精彩评论