Sunday, June 7, 2015

Prevent save as in Excel

The code below can be used to stop any users saving a Workbook as another name and another location.
The code must be placed in the Private Module of the Workbook Object (ThisWorkbook). The fastest way to get there is to right click on the Excel icon, top left next to File and select View Code. It is in here you should place the code below and then save the Workbook. So long as the Workbook is opened with macros enabled the code will fire anytime any user tries to use Save As.
 
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

 If SaveAsUI = True Then Cancel = True

End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)

    Application.ThisWorkbook.Saved = True 'Tells Excel that the _
file has already been saved (this prevents Excel from requesting _
that you save the file when you close it)

End Sub
  Source 
http://www.excel-pratique.com/en/vba_tricks/preventing_a_file_from_being_saved.php 
http://www.ozgrid.com/VBA/prevent-save-as.htm

Wednesday, June 3, 2015

Hide worksheet Excel

Ẩn worksheet trong excel

1. Trước khi ẩn nên Protect sheet trước
Trên thanh Ribbon
Review/ Protect Sheet/ Chọn mật khẩu

2. Ẩn worksheet bằng cửa sổ VBE
Ấn Alt + F11 hiện cửa sổ VBA
View/ Properties Window hay ấn F4
Trong cửa số Properties Window của Sheet muốn ẩn chọn Visible ở gần cuối
Chọn Veryhidden

3. Khóa VBA vào
Cũng trong cửa số VBA
Tool/ VBA Project Properties.../
                      /Proctection/
                               ---> nhập pass

Giấu công thức Excel

Chọn cells cần giấu công thức
Right mouse Click/ Format cells/Protection/ Tick Locked & Hidden

Trên thanh Ribbon
Review /Protect sheet
Đánh mật khẩu ---> Ok