ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel open from VBScript does not display Windows pop-up when file inuse (https://www.excelbanter.com/excel-programming/443460-excel-open-vbscript-does-not-display-windows-pop-up-when-file-inuse.html)

Chrisso

Excel open from VBScript does not display Windows pop-up when file inuse
 
Hi All

I have added some VBScript in the company intranet to open an Excel
file.

The Excel file has no password.

This works fine except when someone already has the Excel file open.

In this case the user (who has clicked my intranet button and opens
the Excel file with the VBScript) does not get the normal Windows pop-
up warning that someone else is in the file. The Excel file just opens
in read-only but the user is not notified.

This will lead to problems as users will not realise and start to add
data. They will only realise when it comes to save and then they will
end up doing a "Save As" and I will end up with multiple copies.

My VBScript looks like this:

Sub OpenWorkbook(strLocation As String)
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = true
objExcel.Workbooks.Open strLocation
objExcel.UserControl = true
End Sub

Has anyone else had this problem and is there a way to ensure the pop-
up occurs.

If this is the wrong forum for this question can you pleaase point me
to the correct place!

Cheers
Chrisso

Jim Rech[_4_]

Excel open from VBScript does not display Windows pop-up when file in use
 
I'd suggest something like this:

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = true
set WB=objExcel.Workbooks.Open(strLocation)
if WB.ReadOnly Then MsgBox "File is read-only"


"Chrisso" wrote in message
...
Hi All

I have added some VBScript in the company intranet to open an Excel
file.

The Excel file has no password.

This works fine except when someone already has the Excel file open.

In this case the user (who has clicked my intranet button and opens
the Excel file with the VBScript) does not get the normal Windows pop-
up warning that someone else is in the file. The Excel file just opens
in read-only but the user is not notified.

This will lead to problems as users will not realise and start to add
data. They will only realise when it comes to save and then they will
end up doing a "Save As" and I will end up with multiple copies.

My VBScript looks like this:

Sub OpenWorkbook(strLocation As String)
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = true
objExcel.Workbooks.Open strLocation
objExcel.UserControl = true
End Sub

Has anyone else had this problem and is there a way to ensure the pop-
up occurs.

If this is the wrong forum for this question can you pleaase point me
to the correct place!

Cheers
Chrisso



Chrisso

Excel open from VBScript does not display Windows pop-up whenfile in use
 
On 5 Aug, 17:55, "Jim Rech" wrote:
I'd suggest something like this:

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = true
set WB=objExcel.Workbooks.Open(strLocation)
if WB.ReadOnly Then MsgBox "File is read-only"

"Chrisso" wrote in message

...



Hi All


I have added some VBScript in the company intranet to open an Excel
file.


The Excel file has no password.


This works fine except when someone already has the Excel file open.


In this case the user (who has clicked my intranet button and opens
the Excel file with the VBScript) does not get the normal Windows pop-
up warning that someone else is in the file. The Excel file just opens
in read-only but the user is not notified.


This will lead to problems as users will not realise and start to add
data. They will only realise when it comes to save and then they will
end up doing a "Save As" and I will end up with multiple copies.


My VBScript looks like this:


Sub OpenWorkbook(strLocation As String)
* *Set objExcel = CreateObject("Excel.Application")
* *objExcel.Visible = true
* *objExcel.Workbooks.Open strLocation
* *objExcel.UserControl = true
End Sub


Has anyone else had this problem and is there a way to ensure the pop-
up occurs.


If this is the wrong forum for this question can you pleaase point me
to the correct place!


Cheers
Chrisso- Hide quoted text -


- Show quoted text -


Many thanks Jim. That will do nicely.

Chrisso


All times are GMT +1. The time now is 10:11 AM.

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