ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programming to VBE (https://www.excelbanter.com/excel-programming/308394-re-programming-vbe.html)

Chip Pearson

Programming to VBE
 
There is no way, other than using SendKeys (unreliable and not
recommended for production code) to programatically protect and
unprotect the VBProject.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ajit" wrote in message
...
I am working on a situation where there are couple of hundred

excel templates
with forms , modules etc. And i need to make a global change in

the code to
one of the procedure. I found some valuable information at

www.cpearson.com
which helped me pragramme to the Visual basic editor.

What i am doing is : I am opening the required template,

finding the
procedure which needs to be replaced , deleting that procedure

and adding a
new procedure with same name but different code.

All works well....except when VBE project is protected.

Could someone suggest a wayout to unprotect the project at

runtime ...make
the required changes and then again protect the project before

saving it.

Suggestions will be highly appreciated.

Thanks
--
Ajit




Hari[_3_]

Programming to VBE
 
Hi Chip,

Why is it considered as unreliable and what does production code mean?

Regards,
Hari
India

"Chip Pearson" wrote in message
...
There is no way, other than using SendKeys (unreliable and not
recommended for production code) to programatically protect and
unprotect the VBProject.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ajit" wrote in message
...
I am working on a situation where there are couple of hundred

excel templates
with forms , modules etc. And i need to make a global change in

the code to
one of the procedure. I found some valuable information at

www.cpearson.com
which helped me pragramme to the Visual basic editor.

What i am doing is : I am opening the required template,

finding the
procedure which needs to be replaced , deleting that procedure

and adding a
new procedure with same name but different code.

All works well....except when VBE project is protected.

Could someone suggest a wayout to unprotect the project at

runtime ...make
the required changes and then again protect the project before

saving it.

Suggestions will be highly appreciated.

Thanks
--
Ajit






Tom Ogilvy

Programming to VBE
 
The success of sendkeys is dependent on what is active on the screen and
where the focus is at the time the keys are sent. As long as you can
guarantee that this will aways be the same and the keys will be interpreted
as intended, then it should be reliable. As much as you can't guarantee
this, then it won't be reliable. Assume you are trying to sendkeys to a
commandbar and someone has altered the commandbar - then you may get
unexpected results.

Production code means code provided as a product or to be executed by the
"user" community. Generally you would want this to be as robust and
reliable as possible. Because of the above considerations, sendkeys isn't
really considered reliable in most cases.

--
Regards,
Tom Ogilvy


"Hari" wrote in message
...
Hi Chip,

Why is it considered as unreliable and what does production code mean?

Regards,
Hari
India

"Chip Pearson" wrote in message
...
There is no way, other than using SendKeys (unreliable and not
recommended for production code) to programatically protect and
unprotect the VBProject.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ajit" wrote in message
...
I am working on a situation where there are couple of hundred

excel templates
with forms , modules etc. And i need to make a global change in

the code to
one of the procedure. I found some valuable information at

www.cpearson.com
which helped me pragramme to the Visual basic editor.

What i am doing is : I am opening the required template,

finding the
procedure which needs to be replaced , deleting that procedure

and adding a
new procedure with same name but different code.

All works well....except when VBE project is protected.

Could someone suggest a wayout to unprotect the project at

runtime ...make
the required changes and then again protect the project before

saving it.

Suggestions will be highly appreciated.

Thanks
--
Ajit









All times are GMT +1. The time now is 08:28 AM.

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