var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Workbook_Close() problem
I am using Private Sub Workbook_Close() to execute some code before the workbook is closed. Even though the user says Cancel when the Save box appers the above code runs. How can this be prevented. I tried using Workbook_DeActivate() but it doesnt work.
Can you post your entire code? (Sanitize if necessary)
This code checks if the file extension in xls or xnv (these extensions generated by excel addin softwares) and calls EnableCopyCutAndPaste only if file extension is not xnv.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim WBkName As String
WBkName = Right(ActiveWorkbook.Name, 3)
If WBkName <> "xnv" Then 'or WBkName = "xls"
Copy/Cut is disabled in xls file on worksheet_open. It is only enabled after xls file is closed, hence the above code.
The problem is that if I select file-->close and then cancel button on the xls file, xls file remains open and the code for Workbook_BeforeClose is also executed thus enabling copy/paste.
I have used a variation from an example at 'The Spread Sheet Page', j-walk.com.
See the example about the middle of the page at this link.
Handling the Workbook BeforeClose Event
Thanks Bill. This is what I needed. Just added Me.Close in VbYes and VbNo so that worksheet is closed. Also if Me.Close is not entered, excel prompts its own Save box again.