View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mike G - D.C. Mike G - D.C. is offline
external usenet poster
 
Posts: 11
Default Workbook_BeforeSave - Prevent use of "x" filename on save or save

I have a workbook (metric chart preview.xls) containing several charts.
Source data for these charts is pushed into the workbook from an Access
Database. Although users will want to manipulate, change, and or modify the
charts within this workbook, any permanent change will break the feed from
the database. Therefore, users must be able to open, manipulate and then save
their own version of the workbook without affecting the original. My initial
thought was to simply set the workbook to read-only to force users into using
Save As and a different File name. This works great to prevent users from
saving changes to the file, however also prevents data update form the Access
Database. My second thought was to disable the Save option and prompt users
to save a copy of the file using Save As with the following
Workbook_BeforeSave code I found while searching this forum,

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI = False Then
MsgBox "Please choose Save As and Rename this file to save your own
version.", vbInformation
Cancel = True
End If
End Sub


This works well enough except users still have the opportunity to save over
the original file. The directory may change depending on user, however, the
original file will always remain as the same. I think what I am looking for
is the ability to prevent the use of "metric chart preview.xls" as a file
name when using the Save or Save As dialogue box. Is there a way to do this?
Thanks, Mike