View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
stainless stainless is offline
external usenet poster
 
Posts: 18
Default Lose macros before saving

I am currently working on a project that is converting Excel 2003 .xls/
xlt files to work in Excel 2010.

What currently happens is an Excel 2003 worksheet is opened
programatically as a local instance on a users laptop i.e. an Excel
2003 .xls file with vba code opens up on their laptop regardless of
whether they have Excel 2003 or2010 installed.

For this to work in both environments, we are having to do the changes
in Excel 2003 so that its is backwards compatible (as opening an xlsm
file from a program would cause more issues than it would solve for
Excel 2003 users).

We have discovered an issue with our code that could be a problem
anyway in Excel 2003 but is more of an issue in 2010.

Currently, once our macros have completed formatting the data in Excel
on the users laptop, they can save these locally and this, sadly,
saves them with the macro automatically in Excel 2003. Not ideal as if
they opened the saved file, they may restart the macro which should
not happen as the data formatting has been completed.

It is clear our usesr have lived with this up ubtil now and I assume
ignore macro failures if they attempt to re-open a saved file.

However, in Excel 2010, they are being asked to save the formatted
file as an xlsx file (probably quite sensible) but this results in an
extra message regarding saving with VBA.

ie "... following features cannot be saved .... VB Project ..."

Although this is not a major issue, it is another potential layer of
confusion.

Note that we do not want to force a save as the user may simply print
and then close.

Therefore, I am wondering if, at the end of the Excel 2003 macro
process, I can add some code that:

1. Copies the now formatted workbook to one that does not contain the
macro (but with the same potentially saved name as the current
workbook, as this macro workbook is originally opened with a suggested
name - guess may need a rename of the running macro workbook before
creating the copy to allow for this).
2. Then shuts down the macro version, thus leaving just a macro free
version for saving

If this happened, then I believe in either Excel 2003 or 2010, there
would be no extra messages and no chance of saving the macro.

Any ideas how I could code for this

Cheers