ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calling a private macro (https://www.excelbanter.com/excel-programming/363669-calling-private-macro.html)

Nick Smith[_2_]

Calling a private macro
 
Folks, just about finished this thing and am now making all the macros
private to prevent tampering only to find that any private macros called
within another macro cannot be found. I get a "Sub or Function Not Defined"
compile error.

Macro being called is "Private Sub ProtectBudgetSheetWithPassword" and the
line Call ProtectBudgetSheetWithPassword fails.

Any ideas?

Thanks,

Nick

Жигайлов Роман

Calling a private macro
 

Folks, just about finished this thing and am now making all the macros
private to prevent tampering only to find that any private macros called
within another macro cannot be found. I get a "Sub or Function Not

Defined"
compile error.

Macro being called is "Private Sub ProtectBudgetSheetWithPassword" and the
line Call ProtectBudgetSheetWithPassword fails.

Any ideas?


Use modules.



Bob Phillips

Calling a private macro
 
Make them Public and precede all macros in the module with

Option Private Module

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Nick Smith" wrote in message
...
Folks, just about finished this thing and am now making all the macros
private to prevent tampering only to find that any private macros called
within another macro cannot be found. I get a "Sub or Function Not

Defined"
compile error.

Macro being called is "Private Sub ProtectBudgetSheetWithPassword" and the
line Call ProtectBudgetSheetWithPassword fails.

Any ideas?

Thanks,

Nick




Norman Jones

Calling a private macro
 
Hi Nick,

See the Run method in VBa help, e.g.:


Application.Run "'YourBook.xls'!Module2.ProtectBudgetSheetWithPass word"

Change Module2 to the name of the module of interest.


---
Regards,
Norman


"Nick Smith" wrote in message
...
Folks, just about finished this thing and am now making all the macros
private to prevent tampering only to find that any private macros called
within another macro cannot be found. I get a "Sub or Function Not
Defined"
compile error.

Macro being called is "Private Sub ProtectBudgetSheetWithPassword" and the
line Call ProtectBudgetSheetWithPassword fails.

Any ideas?

Thanks,

Nick




Mike Fogleman

Calling a private macro
 
Nick, I think you have the wrong idea what Private does. It does not prevent
tampering in the VBEditor, it hides them from certain other macros. As you
have just found out. Macros in a general code module usually are not
private. To prevent code tampering, password protect the VBA Project.

Mike F
"Nick Smith" wrote in message
...
Folks, just about finished this thing and am now making all the macros
private to prevent tampering only to find that any private macros called
within another macro cannot be found. I get a "Sub or Function Not
Defined"
compile error.

Macro being called is "Private Sub ProtectBudgetSheetWithPassword" and the
line Call ProtectBudgetSheetWithPassword fails.

Any ideas?

Thanks,

Nick




Bob Phillips

Calling a private macro
 
I think he is referring to something very basic, if they can't see them from
Excel, they won't touch them.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Mike Fogleman" wrote in message
...
Nick, I think you have the wrong idea what Private does. It does not

prevent
tampering in the VBEditor, it hides them from certain other macros. As you
have just found out. Macros in a general code module usually are not
private. To prevent code tampering, password protect the VBA Project.

Mike F
"Nick Smith" wrote in message
...
Folks, just about finished this thing and am now making all the macros
private to prevent tampering only to find that any private macros called
within another macro cannot be found. I get a "Sub or Function Not
Defined"
compile error.

Macro being called is "Private Sub ProtectBudgetSheetWithPassword" and

the
line Call ProtectBudgetSheetWithPassword fails.

Any ideas?

Thanks,

Nick







All times are GMT +1. The time now is 03:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com