Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Protecting macro code programatically

As an example, I would have my macro test for a name constant in the target
workbook. If it does not exist, the default state, then I would run the
macro. If it did exits, I would exit silently. Then, where you want to add
code to delete that macro, I would set the name constant.

--
__________________________________
HTH

Bob

"Anand Nichkaode" wrote in
message ...
Sorry, but I am not sure I got you fully.

Thanks for the reply


"Bob Phillips" wrote:

That is not designing around it as I see it, that is still trying to
allow
dynamic code deletion.

By designing around it, I mean add some logic so that the macro won't run
in
those circumstances, it will still be there, but dormant.

--
__________________________________
HTH

Bob

"Anand Nichkaode" wrote in
message ...
I know that. And that is why I was trying other approach (refere to the
code
above). But somehow it doesn't work immediately after insert the macro
in
the workbook. I even tried Inserting Macro-Save workbook-Close
Workbook-Open
Workbook-Run Macro approach. It still fails.

Not able to identify what is going wrong.

Thanks for the help.


"Bob Phillips" wrote:

Then you are stuck, there is nothing exposed in the VBE object model
to
allow you to do what you want.

Personally, I think that adding/deleting code/controls dynamically is
not
a
good idea, it is better to design around it IMO.

--
__________________________________
HTH

Bob





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Protecting macro code programatically

Hi Bob,

Thanks for the response.

Continuing our discussion with Protecting macro code programatically, I have
been able do that programatically with SendKeys, but what I observed is that
after Checking "Lock Project for viewing" and putting "Password to view
project properties" when I close the workbook after saving it somehow Macro
code is not password protected. I am doing all this operation from XLAM. I
also observed that even after closing the workbook on which I worked on
(password protect the macro code) I could see the VBAProject still open in
the VB editor. And also I could see the protection in the VBA Project. But
when I re-open the workbook, the macro code is not password protected.

Any info on this would help me a lot as it is really a blocking issue.

Thanks in advance.

"Bob Phillips" wrote:

As an example, I would have my macro test for a name constant in the target
workbook. If it does not exist, the default state, then I would run the
macro. If it did exits, I would exit silently. Then, where you want to add
code to delete that macro, I would set the name constant.

--
__________________________________
HTH

Bob

"Anand Nichkaode" wrote in
message ...
Sorry, but I am not sure I got you fully.

Thanks for the reply


"Bob Phillips" wrote:

That is not designing around it as I see it, that is still trying to
allow
dynamic code deletion.

By designing around it, I mean add some logic so that the macro won't run
in
those circumstances, it will still be there, but dormant.

--
__________________________________
HTH

Bob

"Anand Nichkaode" wrote in
message ...
I know that. And that is why I was trying other approach (refere to the
code
above). But somehow it doesn't work immediately after insert the macro
in
the workbook. I even tried Inserting Macro-Save workbook-Close
Workbook-Open
Workbook-Run Macro approach. It still fails.

Not able to identify what is going wrong.

Thanks for the help.


"Bob Phillips" wrote:

Then you are stuck, there is nothing exposed in the VBE object model
to
allow you to do what you want.

Personally, I think that adding/deleting code/controls dynamically is
not
a
good idea, it is better to design around it IMO.

--
__________________________________
HTH

Bob






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default My solution

Hello there,

i coded a VBA module for Excel that allows to unprotect a VBA project programmatically.
Nope, it does NOT break any password. That's, you need the password for the VBA project that you want to unprotect.

It's just a different way than the SendKeys method.
My method uses win32 messages and timers.

HF ;)

the link :
http://www.twen.name/temp/jb_vbaproj...cker_v1.07.zip

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 533
Default My solution

Very nice piece of work Jérôme! Thanks for donating it to us. It
definitely fills a need.

--
Jim
<gg67 gg67 wrote in message ...
Hello there,

i coded a VBA module for Excel that allows to unprotect a VBA project
programmatically.
Nope, it does NOT break any password. That's, you need the password for
the VBA project that you want to unprotect.

It's just a different way than the SendKeys method.
My method uses win32 messages and timers.

HF ;)

the link :
http://www.twen.name/temp/jb_vbaproj...cker_v1.07.zip



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default My solution

Nice work :-)

But why place the code in "ThisWorkbook" ???

I took the liberty to move the unlocking code to a normal Module, and it
works just as well - so, why place it in "ThisWorkbook"?


PS: I also took the liberty to add support for Danish in 'Main Settings' as
suggested :-)


Keep up the great work,

CE





gg67 gg67 wrote:
Hello there,

i coded a VBA module for Excel that allows to unprotect a VBA project
programmatically.
Nope, it does NOT break any password. That's, you need the password
for the VBA project that you want to unprotect.

It's just a different way than the SendKeys method.
My method uses win32 messages and timers.

HF ;)

the link :
http://www.twen.name/temp/jb_vbaproj...cker_v1.07.zip





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
programatically deleted code still triggers macro warning Ken Excel Programming 4 October 22nd 07 11:41 PM
protecting macro code julian_m Excel Programming 2 January 26th 06 02:23 AM
Deleting macro code programatically Terry Lowe[_3_] Excel Programming 1 September 1st 04 02:30 AM
Hiding/Protecting the code of macro Mario[_6_] Excel Programming 6 January 15th 04 09:06 PM
protecting macro code John Wilson Excel Programming 0 July 23rd 03 04:06 PM


All times are GMT +1. The time now is 11:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"