Private Sub macro error

cjsmile2016

New Member
Joined
Jan 24, 2005
Messages
14
My problem is when I attempt to make the Module VBA private I recieve an error in the workbook section for the EnableCopyCutAndPast or DisableCopyCutAndPaste saying that "Sub or Function not defined". Its works great if I leave the Module at Sub I only get the error when I use Private Sub. Any help would be great...Thank you!!

I'm using this code in my Module:

Sub DisableCopyCutAndPaste()
EnableControl 21, False ' cut
EnableControl 19, False ' copy
EnableControl 22, False ' paste
EnableControl 755, False ' pastespecial
EnableControl 848, False ' move/copy sheet
Application.OnKey "^c", "Dummy"
Application.OnKey "^v", "Dummy"
Application.OnKey "+{DEL}", "Dummy"
Application.OnKey "+{INSERT}", "Dummy"
Application.CellDragAndDrop = False
Application.OnDoubleClick = "Dummy"
CommandBars("ToolBar List").Enabled = False
End Sub

Sub EnableCopyCutAndPaste()
EnableControl 21, True ' cut
EnableControl 19, True ' copy
EnableControl 22, True ' paste
EnableControl 755, True ' pastespecial
EnableControl 848, True ' move/copy sheet
Application.OnKey "^c"
Application.OnKey "^v"
Application.OnKey "+{DEL}"
Application.OnKey "+{INSERT}"
Application.CellDragAndDrop = True
Application.OnDoubleClick = ""
CommandBars("ToolBar List").Enabled = True
End Sub

and using this in my workbook:

Private Sub Workbook_Open()
UnhideSheets
DisableCopyCutAndPaste
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
HideSheets
EnableCopyCutAndPaste
End Sub

Thanks again,
Tim
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Are they all in ThisWorkbook module ?

Edit: For example; you have to also place the procedure named EnableControl in ThisWorkbook module and then you may have it private.
 
Upvote 0
I beleive part of my problem is I'm not sure where to place the EnableControl function. I've tried just about everywhere with no success. Any help out there please?!
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,843
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top