ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Able to open same excel workbook at the same time ! (https://www.excelbanter.com/excel-programming/361053-able-open-same-excel-workbook-same-time.html)

ann[_3_]

Able to open same excel workbook at the same time !
 
Hi Everyone !
I m a newbie to excel programming but I noticed a bug (??) while
working with excel & VS.NET. I m able to open an excel workbook in 2
different instances of my application & I cant find a way to prevent
this from happening. As a result, 2 different users can , effectively
work on the same workbook, on a same worksheet & over-ride each other's
saves !!
Pls help if anyone has faced a similar problem & if there is anyway to
prevent this !

Thanks in advance
~Ann


Bob Phillips[_14_]

Able to open same excel workbook at the same time !
 
Surely, one of them will open it as read-only, thereby not being able to
write it back. You can test for this property.

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"ann" wrote in message
ups.com...
Hi Everyone !
I m a newbie to excel programming but I noticed a bug (??) while
working with excel & VS.NET. I m able to open an excel workbook in 2
different instances of my application & I cant find a way to prevent
this from happening. As a result, 2 different users can , effectively
work on the same workbook, on a same worksheet & over-ride each other's
saves !!
Pls help if anyone has faced a similar problem & if there is anyway to
prevent this !

Thanks in advance
~Ann




ann[_3_]

Able to open same excel workbook at the same time !
 
That is the problem neither Excel or XP (the OS I am using it with)
detects this & allows me to open & work on the same workbook at the
same time. !

Is there someway to check in C# if a file is already open ?
I found a lot of code using VB that allows a file to be locked while
opening and thereby detecting another open attempt on an already open
file.
Cannot find anything similar in C#

Thanks


Bob Phillips[_14_]

Able to open same excel workbook at the same time !
 
Don't know C#, but as I said, if you open it and then check it's ReadOnly,
which is

ActiveWorkbook.ReadOnly

in VBA, and act accordingly.

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"ann" wrote in message
ups.com...
That is the problem neither Excel or XP (the OS I am using it with)
detects this & allows me to open & work on the same workbook at the
same time. !

Is there someway to check in C# if a file is already open ?
I found a lot of code using VB that allows a file to be locked while
opening and thereby detecting another open attempt on an already open
file.
Cannot find anything similar in C#

Thanks




ann[_3_]

Able to open same excel workbook at the same time !
 
Thanks for your prompt replies Bob.
I realised that the solution lies in using the VBA. I was using Interop
till now.
I was able to check if the file is already open using VBA.FileOpen
method.



All times are GMT +1. The time now is 01:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com