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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Haluk

Rules Violation
Joined
Oct 26, 2002
Messages
1,075
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.
 

cjsmile2016

New Member
Joined
Jan 24, 2005
Messages
14
I tried using the EnableControl and I still recieve an error message. Any clue what I could be doing wrong?
 

cjsmile2016

New Member
Joined
Jan 24, 2005
Messages
14
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?!
 

Forum statistics

Threads
1,148,056
Messages
5,744,548
Members
423,882
Latest member
Seeham

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
Top