ActiveWorkbook.Close Dont Work in Excel 2007

K

K

Hi all, I got Excel 2007. The Macro line below works fine in older
excel versions.
ActiveWorkbook.Close
But when i put this code in Excel 2007 and click the button it closes
the workbook but also give the error and start sending error report to
Microsoft and open up the blank sheet after recovering it. How can i
close an Excel 2007 Workbook on button click. Please can anybody help
 
R

Ron de Bruin

Hi K

Maybe this is your problem?
If a macro that closes an Excel workbook is assigned to a shape, clicking it in Excel 2007 will cause a crash.

If this is so use a button to run the code
 
K

K

Hi K

Maybe this is your problem?
If a macro that closes an Excel workbook is assigned to a shape, clickingit in Excel 2007 will cause a crash.

If this is so use a button to run the code

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm





- Show quoted text -

Hi Ron, Thanks for replying. What should i do if i want to assigne
"ActiveWorkbook.Close" macro to a shape not to a Form Contorl or
Active X Control button. i want to do this as i can make nice looking
button with shape and can make my spreadsheet looking more
proffessional which i can't do with other buttons. Other buttons are
very simple but with shape i can create nice glossy looking button.
 
R

Ron de Bruin

Hi K

Sorry I not know a workaround

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


Hi K

Maybe this is your problem?
If a macro that closes an Excel workbook is assigned to a shape, clicking it in Excel 2007 will cause a crash.

If this is so use a button to run the code

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm





- Show quoted text -

Hi Ron, Thanks for replying. What should i do if i want to assigne
"ActiveWorkbook.Close" macro to a shape not to a Form Contorl or
Active X Control button. i want to do this as i can make nice looking
button with shape and can make my spreadsheet looking more
proffessional which i can't do with other buttons. Other buttons are
very simple but with shape i can create nice glossy looking button.
 
D

Dave Peterson

Hi, Ron.

That's an ugly bug/feature(???).

(Don't get mad at this)

Are you going to create a page on your site that deals with things that xl2007
can't do? Maybe with some alternative suggestions that are links to your other
pages.

This may turn into a giant list <vbg>.

I tried this.

Option Explicit
Sub testme()
Application.OnTime Now + TimeSerial(0, 0, 1), ThisWorkbook.Name & "!CloseMe"
End Sub
Sub CloseMe()
ActiveWorkbook.Close savechanges:=False
End Sub

And it seemed to work ok when I assigned the Testme subroutine to a shape
(tested with 2 random shapes).

To the OP:
You may want to take a look at Chip Pearson's notes on .ontime:
http://www.cpearson.com/excel/OnTime.aspx
 

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