how to avoid user to save in .xlsx

M

Mathieu936

Hi!

I have an add-in (.xlam) which copies a worksheet (which contains a
Sub worksheet_calculate) in the current workbook.

However, if the current workbook is an .xlsx format, and the user
still saves in .xlsx format (regardless the message box saying that
the macro will be deleted), the new inserted worksheet will lost its
Sub worksheet_calculate.

I really need to keep the Sub worksheet_calculate.

Is there any code/fonction/way to avoid that the used save in .xlsx?
The current workbook can be an existing file with .xlsx format, or a
new freshly created workbook.

Thanks!
 
D

Don Guillett Excel MVP

Hi!

I have an add-in (.xlam) which copies a worksheet (which contains a
Sub worksheet_calculate) in the current workbook.

However, if the current workbook is an .xlsx format, and the user
still saves in .xlsx format (regardless the message box saying that
the macro will be deleted), the new inserted worksheet will lost its
Sub worksheet_calculate.

I really need to keep the Sub worksheet_calculate.

Is there any code/fonction/way to avoid that the used save in .xlsx?
The current workbook can be an existing file with .xlsx format, or a
new freshly created workbook.

Thanks!

Look in the ThisWorkbook module for before save and stop it within
that.
 
M

Mathieu936

Look in the ThisWorkbook module for before save and stop it within
that.- Masquer le texte des messages précédents -

I tried it but the BeforeSave event happens before saving. So I could
popup a message box saying to not save in .xlsx, but after user could
save in .xlsx which is bad.
 
C

Charlotte E

You could make the 'BeforeSave' event force-save the workbook as .XLSm, set
Cancel = True after the saving is done, and perhaps let a MsgBox inform the
user that the workbook was saved as .XLSm instead of .XLSx

CE



"Mathieu936" <[email protected]> skrev i en meddelelse
Look in the ThisWorkbook module for before save and stop it within
that.- Masquer le texte des messages précédents -

I tried it but the BeforeSave event happens before saving. So I could
popup a message box saying to not save in .xlsx, but after user could
save in .xlsx which is bad.
 

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