J
Jonsson
Hi,
I have tried to construct a code to open the workbook withou
commandbars and without the cut-function.
But when I open the workbook, I get "compile-error", and when openin
the module it says I need to define the type
"Dim oCtls As CommandBarsControls".
I use this in a workbook that contains a lot of macros and sheets, bu
when I test in a new workbook it works fine.
Can anyone help to get it right?
Here´s the code:
Sub Aut
pen()
With ActiveWindow
Application.CommandBars(1).Enabled = False 'True to restore
.DisplayHeadings = False
.DisplayWorkbookTabs = False
End With
Application.CommandBars("Standard").Visible = False
Application.CommandBars("Formatting").Visible = False
Application.CommandBars("Forms").Visible = False
Application.CommandBars("Drawing").Visible = False
Application.CommandBars("Visual Basic").Visible = False
Dim oCtls As CommandBarControls
Dim oCtl As CommandBarControl
Set oCtls = CommandBars.FindControls(ID:=21) ''Cut
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
oCtl.Enabled = False
Next
End If
Set oCtls = CommandBars.FindControls(ID:=522) ''Options
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
oCtl.Enabled = False
Next
End If
With Application
.OnKey "^x", ""
.OnKey "+{Del}", ""
.CellDragAndDrop = False
End With
End Sub
Function Auto_Close()
With ActiveWindow
Application.CommandBars(1).Enabled = True 'True to restore
.DisplayHeadings = False
End With
Application.CommandBars("Standard").Visible = True
Application.CommandBars("Formatting").Visible = True
Application.CommandBars("Drawing").Visible = True
Dim oCtls As CommandBarControls, oCtl As CommandBarControl
Set oCtls = CommandBars.FindControls(ID:=21)
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
oCtl.Enabled = True
Next
End If
Set oCtls = CommandBars.FindControls(ID:=522)
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
oCtl.Enabled = True
Next
End If
With Application
.OnKey "^x"
.OnKey "+{Del}"
.CellDragAndDrop = True
End With
Application.Quit
End Functio
I have tried to construct a code to open the workbook withou
commandbars and without the cut-function.
But when I open the workbook, I get "compile-error", and when openin
the module it says I need to define the type
"Dim oCtls As CommandBarsControls".
I use this in a workbook that contains a lot of macros and sheets, bu
when I test in a new workbook it works fine.
Can anyone help to get it right?
Here´s the code:
Sub Aut
With ActiveWindow
Application.CommandBars(1).Enabled = False 'True to restore
.DisplayHeadings = False
.DisplayWorkbookTabs = False
End With
Application.CommandBars("Standard").Visible = False
Application.CommandBars("Formatting").Visible = False
Application.CommandBars("Forms").Visible = False
Application.CommandBars("Drawing").Visible = False
Application.CommandBars("Visual Basic").Visible = False
Dim oCtls As CommandBarControls
Dim oCtl As CommandBarControl
Set oCtls = CommandBars.FindControls(ID:=21) ''Cut
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
oCtl.Enabled = False
Next
End If
Set oCtls = CommandBars.FindControls(ID:=522) ''Options
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
oCtl.Enabled = False
Next
End If
With Application
.OnKey "^x", ""
.OnKey "+{Del}", ""
.CellDragAndDrop = False
End With
End Sub
Function Auto_Close()
With ActiveWindow
Application.CommandBars(1).Enabled = True 'True to restore
.DisplayHeadings = False
End With
Application.CommandBars("Standard").Visible = True
Application.CommandBars("Formatting").Visible = True
Application.CommandBars("Drawing").Visible = True
Dim oCtls As CommandBarControls, oCtl As CommandBarControl
Set oCtls = CommandBars.FindControls(ID:=21)
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
oCtl.Enabled = True
Next
End If
Set oCtls = CommandBars.FindControls(ID:=522)
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
oCtl.Enabled = True
Next
End If
With Application
.OnKey "^x"
.OnKey "+{Del}"
.CellDragAndDrop = True
End With
Application.Quit
End Functio