Replace lines of code in vba

i have this line of code in some procedure,i would like to replace the line of code with the procedure name
Const PROC_NAME As String = "TEST_RUN" should be replace with Const PROC_NAME As String = "function or sub name"
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
You can't. That's why it is called a constant.

So, declare using Dim:

Dim PROC_NAME As String
PROC_NAME = SomeFunctionReturningAString() 

Open in new window

Daniel PineaultPresident / Owner CARDA Consultants Inc.Commented:
You can use a tool like Mz-Tools to facilitate the process as part of your error handler.
I used Daniel's approach to add a Const statement with the routine name.  I did this to facilitate logging.  For this, I used a MZTools find/replace operation using regular expressions to capture the routine name.
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

Martin LissOlder than dirtCommented:
Mz-Tools is great but once you used its "Options->Procedure Header" menu item function to design what you want a procedure header to look like, you would then need to use click its "Add Procedure Header" button in every procedure where you wanted the header.

Another choice is to use my Automatic Insertion of Procedure Names add-in which will automate the process.
John TsioumprisSoftware & Systems EngineerCommented:
The only way i know about usage of Const and Event procedure is in the case of event sinking
Take a look here
Private WithEvents chkbx As CheckBox
Private m_Form As Form
Private Const mstrEventProcedure = "[Event Procedure]"

Public Function init(chkbox As CheckBox, frm As Form)
  Set chkbx = chkbox
  Set m_Form = frm
  'Debug.Print frm.Name
  chkbx.AfterUpdate = mstrEventProcedure
End Function

Open in new window

It might be useful to desribe your needs in order to get better hel
Martin LissOlder than dirtCommented:
The only way i know about usage of Const and Event procedure is in the case of event sinking
My add-in automates that.
One replace operation works for an entire module/form/report.
SvgmassiveAuthor Commented:
can i use a find and replace method to replace test_run with the procedure name.
John TsioumprisSoftware & Systems EngineerCommented:
Simple Find/ Replace should be sufficient if there aren't too many.
If its a complex task then you should use Find and Replace addin
Gustav BrockCIOCommented:
You can also use MZ-Tools to locate and list where, say, a constant are in use:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.