Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Prevent Access To VBA Editor?

Hello all,
Is there a way I can prevent a user accessing the VBA Editor?
Thanks.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Prevent Access To VBA Editor?

Hello Matthew,

Do you mean you would like to hide the code?
If so, you can set the password to the VBAproject from Tools Propert
of the VBE project see the second tab

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Prevent Access To VBA Editor?

Hi Matthew

You can do this via VBA code

------------------------------------------
Sub Prevent_VBA(

With Applicatio

.Commandbars("Tools").Controls("Macro").Enabled = Fals
.Commandbars("Visual Basic").FindControl(id=1695).Enabled = Fals
.OnKey "%{F11}", "
.VBE.MainWindow.Visible = Fals
------------------------------------------

This will disable the Tools--Macro menu (where you can open VBA Editor from), nullify the VBE toolbar button (in case the user tries to add the button from the Tools--Customize), nullify the Alt-F11 shortcut, and close the VBE if it's already open

Just remember to re-enable all these before you leave, or else you wouldn't have very happy users! =

SuperJas.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Prevent Access To VBA Editor?

You will need to disable more then just that.....

Option Explicit
'//
'// Tested Excel2000
'// Run DisableGettingIntoVBE from an Event procedure
'// eg. Workbook_Open or Worksheet_Activate
'// THEN run EnableGettingIntoVBE from the Opp Event procedure
'// eg. Workbook_Close or Worksheet_Deactivate
'//================================================== ===================
'// Note:
'// In order to Disable access into the VBA Editor
'// you must Disable ALL references to Access the code
'// eg Macros...dialog, View Code - available via RighClick on Sheet Tab
'// Record New Macro..., Design Mode as the User can put the
'// workbook in design mode then select a control & double click to
'// view code, right click top Document Area etc
'// Also you need to Disable the Custom Toolbar List AND
'// the fact that Double clicking ANY area of the commandbars will
'// also give you the Customize Toolbars Option Dialog.

'// The following Routine Takes care of this.

Const dCustomize As Double = 797
Const dVbEditor As Double = 1695
Const dMacros As Double = 186
Const dRecordNewMacro As Double = 184
Const dViewCode As Double = 1561
Const dDesignMode As Double = 1605
Const dAssignMacro As Double = 859

Sub DisableGettingIntoVBE()
Application.VBE.MainWindow.Visible = False '// Close ALL VBE Windows 1st!
CmdControl dCustomize, False '// Customize
CmdControl dVbEditor, False '// &Visual Basic Editor
CmdControl dMacros, False '// Macros...
CmdControl dRecordNewMacro, False '// Record New Macro...
CmdControl dViewCode, False '// View Code
CmdControl dDesignMode, False '// Design Mode
CmdControl dAssignMacro, False '// Assig&n Macro...

Application.OnDoubleClick = "Dummy"
Application.CommandBars("ToolBar List").Enabled = False
Application.OnKey "%{F11}", "Dummy"
End Sub

Sub EnableGettingIntoVBE()
CmdControl dCustomize, True '// Customize
CmdControl dVbEditor, True '// &Visual Basic Editor
CmdControl dMacros, True '// Macros...
CmdControl dRecordNewMacro, True '// Record New Macro...
CmdControl dViewCode, True '// View Code
CmdControl dDesignMode, True '// Design Mode
CmdControl dAssignMacro, True '// Assig&n Macro...

Application.OnDoubleClick = vbNullString
Application.CommandBars("ToolBar List").Enabled = True
Application.OnKey "%{F11}"
End Sub

Sub Dummy()
'// NoGo, leave blank OR Display a message eg.
MsgBox "Sorry this command is NOT available", vbCritical
End Sub

Sub CmdControl(Id As Integer, TF As Boolean)
Dim CBar As CommandBar
Dim C As CommandBarControl

On Error Resume Next
For Each CBar In Application.CommandBars
Set C = CBar.FindControl(Id:=Id, Recursive:=True)
If Not C Is Nothing Then C.Enabled = TF
Next

Set C = Nothing

End Sub



"SuperJas" wrote in message ...
Hi Matthew,

You can do this via VBA code:

-------------------------------------------
Sub Prevent_VBA()

With Application

.Commandbars("Tools").Controls("Macro").Enabled = False
.Commandbars("Visual Basic").FindControl(id=1695).Enabled = False
.OnKey "%{F11}", ""
.VBE.MainWindow.Visible = False
-------------------------------------------

This will disable the Tools--Macro menu (where you can open VBA Editor from), nullify the VBE toolbar button (in case the user tries to add the button from the Tools--Customize), nullify the Alt-F11 shortcut, and close the VBE if it's already open.

Just remember to re-enable all these before you leave, or else you wouldn't have very happy users! =)

SuperJas.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Prevent Access To VBA Editor?

Thanks all. I'll look into all of these options.

"Ivan F Moala" wrote in message
om...
You will need to disable more then just that.....

Option Explicit
'//
'// Tested Excel2000
'// Run DisableGettingIntoVBE from an Event procedure
'// eg. Workbook_Open or Worksheet_Activate
'// THEN run EnableGettingIntoVBE from the Opp Event procedure
'// eg. Workbook_Close or Worksheet_Deactivate
'//================================================== ===================
'// Note:
'// In order to Disable access into the VBA Editor
'// you must Disable ALL references to Access the code
'// eg Macros...dialog, View Code - available via RighClick on Sheet Tab
'// Record New Macro..., Design Mode as the User can put the
'// workbook in design mode then select a control & double click to
'// view code, right click top Document Area etc
'// Also you need to Disable the Custom Toolbar List AND
'// the fact that Double clicking ANY area of the commandbars will
'// also give you the Customize Toolbars Option Dialog.

'// The following Routine Takes care of this.

Const dCustomize As Double = 797
Const dVbEditor As Double = 1695
Const dMacros As Double = 186
Const dRecordNewMacro As Double = 184
Const dViewCode As Double = 1561
Const dDesignMode As Double = 1605
Const dAssignMacro As Double = 859

Sub DisableGettingIntoVBE()
Application.VBE.MainWindow.Visible = False '// Close ALL VBE

Windows 1st!
CmdControl dCustomize, False '// Customize
CmdControl dVbEditor, False '// &Visual Basic Editor
CmdControl dMacros, False '// Macros...
CmdControl dRecordNewMacro, False '// Record New Macro...
CmdControl dViewCode, False '// View Code
CmdControl dDesignMode, False '// Design Mode
CmdControl dAssignMacro, False '// Assig&n Macro...

Application.OnDoubleClick = "Dummy"
Application.CommandBars("ToolBar List").Enabled = False
Application.OnKey "%{F11}", "Dummy"
End Sub

Sub EnableGettingIntoVBE()
CmdControl dCustomize, True '// Customize
CmdControl dVbEditor, True '// &Visual Basic Editor
CmdControl dMacros, True '// Macros...
CmdControl dRecordNewMacro, True '// Record New Macro...
CmdControl dViewCode, True '// View Code
CmdControl dDesignMode, True '// Design Mode
CmdControl dAssignMacro, True '// Assig&n Macro...

Application.OnDoubleClick = vbNullString
Application.CommandBars("ToolBar List").Enabled = True
Application.OnKey "%{F11}"
End Sub

Sub Dummy()
'// NoGo, leave blank OR Display a message eg.
MsgBox "Sorry this command is NOT available", vbCritical
End Sub

Sub CmdControl(Id As Integer, TF As Boolean)
Dim CBar As CommandBar
Dim C As CommandBarControl

On Error Resume Next
For Each CBar In Application.CommandBars
Set C = CBar.FindControl(Id:=Id, Recursive:=True)
If Not C Is Nothing Then C.Enabled = TF
Next

Set C = Nothing

End Sub



"SuperJas" wrote in message

...
Hi Matthew,

You can do this via VBA code:

-------------------------------------------
Sub Prevent_VBA()

With Application

.Commandbars("Tools").Controls("Macro").Enabled = False
.Commandbars("Visual Basic").FindControl(id=1695).Enabled = False
.OnKey "%{F11}", ""
.VBE.MainWindow.Visible = False
-------------------------------------------

This will disable the Tools--Macro menu (where you can open VBA Editor

from), nullify the VBE toolbar button (in case the user tries to add the
button from the Tools--Customize), nullify the Alt-F11 shortcut, and close
the VBE if it's already open.

Just remember to re-enable all these before you leave, or else you

wouldn't have very happy users! =)

SuperJas.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
prevent reading or any access to selected cells R New Users to Excel 2 August 26th 09 10:06 PM
Unable to access VBA editor [email protected] Excel Discussion (Misc queries) 6 January 22nd 08 03:41 PM
Prevent Access To already open file ashtod1 New Users to Excel 0 January 5th 06 10:57 PM
How can I prevent access to code contained within Tab Lee Excel Worksheet Functions 1 September 21st 05 12:42 AM
How do I prevent data truncation from access to excel using MS Qu. ktw_jax1 Excel Worksheet Functions 1 March 7th 05 06:09 PM


All times are GMT +1. The time now is 02:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"