Workbook_BeforeClose(Cancel As Boolean) - Cancel won't work


G

gpmichal

Please help...

I'm tyring to use the Workbook_BeforeClose event in an Excel 2007
ThisWorkbook object. When the code sets the Cancel parameter to "True", the
workbook isn't supposed to close. For testing purposes, I used the following
code on several computers:


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
End Sub

On my home computer, and others at work, the code works fine (the workbook
won't close). On some work computers, including my own, the workbook closes.
This is very frustrating.

All computers are using the same operating system; Windows XP Professional
Version 2002 SP3 and the same software; Office 2007 SP2 with Microsoft Office
Excel 2007 (12.0.6425.1000) SP2 MSO (12.0.6425.1000).

I don't want to uninstall and reinstall Office 2007 to try and correct the
issue becuase my local TSE at work doesn't want to have to do this to several
computers that are having the issue. He would rather find out what is
causing the issue and post a fix on the server for the users to install.

I've researched for hours on end trying to find out what might be causing
this but came up with nothing. I called Microsoft to see if they could help
but all they want to do is charge me $260 for an incident ticket. I'm upset
about that because the software was only installed on my computer in January
2009 and others, less than 2 weeks ago. I would expect a warranty to cover
the cost. They said that because the issue is occuring on computers
connected to a network and involves a macro, they have to charge for
Professional support.

Can anyone out there help?

Thanks for listening,

GPMichal
 
Ad

Advertisements

G

gpmichal

Please diregard. I posted this question in Microsoft.Pubic.Excel.Programming
instead.
 
Ad

Advertisements

Joined
Apr 22, 2010
Messages
5
Reaction score
3
My dear wise audience,

because I have the very same problem, I found this thread via google.
(Why can't I find it via internal search?)

As I can't find any, resp. "the" follow-up thread and not any other solution, I'm asking here for help.

My problem in detail:

I have Excel 2003 and Win XP SP3.

I have tested the following code:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim v_result As VbMsgBoxResult
v_result = MsgBox("Are you sure?", vbOKCancel, "Close Workbook?")

If v_result <> vbOK Then
Cancel = True 'should stop Closing, but doesn't work
End If
End Sub

I have tested it on my Laptop with my old, original Login and with a just newly created login. In both cases the MsgBox pops up but whatever I click, the worksheet closes.

I have asked a colleague with a very similar Computer (HW+SW).
With his login it works as expected.

So what is the causal difference?
What/which Options, registry-entries, ... do I have to check?

Thx for any help.

gpmichal said:
Please diregard. I posted this question in Microsoft.Pubic.Excel.Programming
instead.

"gpmichal" wrote:

> Please help...
>
> I'm tyring to use the Workbook_BeforeClose event in an Excel 2007
> ThisWorkbook object. When the code sets the Cancel parameter to "True", the
> workbook isn't supposed to close. For testing purposes, I used the following
> code on several computers:
>
>
> Private Sub Workbook_BeforeClose(Cancel As Boolean)
> Cancel = True
> End Sub
>
....
> GPMichal
 

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