Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 26th, 2006, 02:43 PM
Registered User
 
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Disable User Saving in Excel

I have an application I have developed in Excel. I don't want the user to be able to save the sheet but I still need the ability to save via VBA on occasion so I can't make the file Read Only. Does anyone know a way to disable file saving using VBA?

Thanks
 
Old September 26th, 2006, 08:52 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Use the Workbook_BeforeSave event to disallow saves

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    MsgBox "Cannot Save File", vbInformation, "Wrox Test"
    Cancel = True
End Sub

However, you can disable the event in your code to save the file

Private Sub Save_Using_VBA()

    Application.EnableEvents = False

    '--- Write the code to Save Workbook

    Application.EnableEvents = True

End Sub

Cheers:)
Shasur

http://www.vbadud.blogspot.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to disable GridView delete button for a user rao965 ASP.NET 2.0 Professional 0 May 9th, 2008 12:30 PM
Generating user instances in SQL Server is disable oa1111 ASP.NET 2.0 Basics 0 August 17th, 2007 10:34 AM
Disable User control in Windows Sebastiaan VBScript 3 June 17th, 2007 04:20 PM
How to disable saving file in TEMP Folder sandeep.kharat ASP.NET 2.0 Basics 0 April 27th, 2006 12:43 AM
EXCEL question saving a file saving the the first macupryk VS.NET 2002/2003 0 January 6th, 2005 05:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.