Changing default response of an alert through vba

R

Raj

Hi,

To avoid an alert being displayed when an open workbook is attempted
to be re-opened, I am using the following code:

On Error Resume Next
Application.DisplayAlerts = False
Workbooks.Open rspdir & rspstring1

This works fine and the alert display is suppressed. But the default
response of the alert ie. "Yes" :eek:pen the workbook is used. I want
the response "No" to be used ie. I do not want the workbook to be
opened again if the workbook is already open.

Can the default response of an alert be changed when the displayalerts
property is set to false?

If not, is there any other code I can use to open a workbook only if
it is not open?

Thanks in advance for the help.

Regards,
Raj
 
B

Bob Phillips

Test if the workbook is open if so don't even try to open it

On Error Resume Next
Set wb = Workbooks("Some workbook.xls")
On Error Goto 0
If wb is Nothing Then

eet wb=Workbooks.Open("Some workbook.xls")
End If

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

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