Function to perform on closing an Excel Workbook

P

PaddyMac

I wish to automate the closing of an Excel workbook so that Excel does
not save any changes, but does save what has been copied to the
clipboard.

I have got as far as.

ActiveWorkbook.Close

and am stuck

Any ideas?

Many thanks.

Kind regards

PaddyMac
 
T

Tim Williams

Try this:

Sub Tester()
Application.DisplayAlerts = False
ActiveWorkbook.Close False
Application.DisplayAlerts = True
End Sub

Tim
 
J

Jarek Kujawa

1. where would you like the clipboard to be saved?
....
2. to ignore saving changes do as follows:
press ALT+F11 to get to VBA window
then in Project-VBAProject double click on ThisWorkbook object
select Workbook in a window where (General) is displayed
select BeforeClose in the rightmost window

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
ActiveWorkbook.Close savechanges:=False
End Sub
 
P

PaddyMac

Tim

I am so sorry for not responding sooner - your message has only just shown up.

I'll try it out tomorrow morning

Many thanks.

Kind regards

Ian
 
P

PaddyMac

jaarek

Sorry for not responding sooner - your post has only just shown up.

I'll try it tomorrow morning.

many thanks!

Kind regards

PaddyMac
 

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