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

C

Chrisso

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
 
J

Jim Rech

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"
 
C

Chrisso

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"
















- Show quoted text -

Many thanks Jim. That will do nicely.

Chrisso
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top