A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Save Button



 
 
Thread Tools Display Modes
  #1  
Old July 23rd, 2004, 09:00 AM
external usenet poster
 
Posts: n/a
Default Save Button

Is there any way you can make the save and save as buttons
in excel password protected or hidden for a specific
spread sheet. I want to produce a template where users can
imput their results and excel will calculate the results
and let you print it off but not allow you to save it.
  #2  
Old July 23rd, 2004, 11:02 AM
Frank Kabel
external usenet poster
 
Posts: n/a
Default Save Button

Hi
you can put the following code in your workbook module


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
cancel=true
End Sub



--
Regards
Frank Kabel
Frankfurt, Germany


wrote:
Is there any way you can make the save and save as buttons
in excel password protected or hidden for a specific
spread sheet. I want to produce a template where users can
imput their results and excel will calculate the results
and let you print it off but not allow you to save it.


  #3  
Old July 23rd, 2004, 11:41 AM
BrianB
external usenet poster
 
Posts: n/a
Default Save Button

Presumably you will want to save it.

This checks the network user name.


Code:
--------------------

'=============================================
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
'------------------------------------------
'-
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim UserName As String
'- Network Login Name
UserName = OSUserName
If UserName "SmithF" Then
MsgBox ("You cannot save this file")
Cancel = True
End If
End Sub
'-
'-----------------------------------
Function OSUserName() As String
'-----------------------------------
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX 0) Then
OSUserName = Left$(strUserName, lngLen - 1)
Else
OSUserName = vbNullString
End If
End Function
'==============================================

--------------------



---
Message posted from http://www.ExcelForum.com/

  #4  
Old July 23rd, 2004, 11:58 AM
Frank Kabel
external usenet poster
 
Posts: n/a
Default Save Button

Hi
a different solution:
- enter this code
- in the VBA editor in the immediate window enter
application.enableevents=false
- save the file
- enter the statement
application.enableevents=True

--
Regards
Frank Kabel
Frankfurt, Germany


Presumably you will want to save it.

This checks the network user name.


Code:
--------------------

'=============================================
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
'------------------------------------------
'-
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel
As Boolean) Dim UserName As String
'- Network Login Name
UserName = OSUserName
If UserName "SmithF" Then
MsgBox ("You cannot save this file")
Cancel = True
End If
End Sub
'-
'-----------------------------------
Function OSUserName() As String
'-----------------------------------
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX 0) Then
OSUserName = Left$(strUserName, lngLen - 1)
Else
OSUserName = vbNullString
End If
End Function
'==============================================

--------------------



---
Message posted from http://www.ExcelForum.com/

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling Save Button Andrew General Discussion 1 June 24th, 2004 02:53 PM
Hide Menu Bar / Toolsbar / disable save button? Param Worksheet Functions 0 June 14th, 2004 05:45 PM
Save in location button Ravi Sandhu Worksheet Functions 2 February 6th, 2004 10:28 PM
Button Error - Save at location Ravi Sandhu Worksheet Functions 2 February 5th, 2004 10:17 PM
Button - Save Location Ravi Sandhu Worksheet Functions 0 February 3rd, 2004 10:07 PM


All times are GMT +1. The time now is 05:08 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.