Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Programmatically Open Locked VBAProject

I'd like to open a password protected VBAProject via code, copy out specific
modules, then close the project (add-in).

I have an add-in that I share with multiple functions that are used by
users. I have the add-in VBAProject password protected. This is enough to
keep the nosey out. I know it is NOT secure.

Now, I would like the user to copy modules (that I have specified) out of
the add-in vbaproject to their workbook. I have the code to copy the module
but I cannot do it if the add-in project is locked.

How do I open the add-in VBAProject, pass the password to it, then close it
again after it the copy module function is complete?

One Response:
What you are asking is considered hacking and you will not get any help here
as it is against board policy. You may have to find a different way to make
your code available to the user.


My Reply:
Okay. If it considered hacking. How do I go about sharing portions of my
code but not all of it that is contained inside my add-in without allowing
all of my code to be exposed to nosey users?

Is it still considered hacking if I know what the password is and pass it
via code to open it? For example, while researching on here, I found posts of
how to pass the password to a protected sheet to unprotect it. Is that not
the same thing?

Why is it considered hacking if I wrote the code that is protected and
placed the password protection?

If there is a better way to copy specific modules from my password-protected
(where I created and know the password) add-in to a users workbook, please
let me know.
  #2   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Programmatically Open Locked VBAProject

Hi Michael,

Personally, I would not consider this to be hacking; but what do I know?

Unfortunately, I think the only way to do this is to use send keys (but I
could be wrong). The following function works splendidly for me. You need to
be sure that "Trust access to visual basic project" is checked in the source
file you are trying to access, and also, set a reference to "MICROSOFT VISUAL
BASIC FOR APPLICATIONS EXTENSIBILITY" for this to work.

Note that this function below unlocks the project of the current file, I
haven't tried it to unlock a different file, but it seems like you should be
able to manipulate the function to unlock the VBE in a specified file (which
may need to be activated first).

Call the function like so:

Call UnlockVBAProject(MyPassword)

Here is the function placed in a standard code module:

Private Function UnLockVBAProject(argPWD As String)
'unlock VBA project:
Dim VBP As VBProject
Set VBP = ThisWorkbook.VBProject
If VBP.Protection < vbext_pp_locked Then Exit Function
Application.ScreenUpdating = True
DoEvents
SendKeys "%{F11}%TE" & argPWD & "~~%{F11}", True
DoEvents
End Function

This may help at least to get you started.

"Michael PE" wrote:

I'd like to open a password protected VBAProject via code, copy out specific
modules, then close the project (add-in).

I have an add-in that I share with multiple functions that are used by
users. I have the add-in VBAProject password protected. This is enough to
keep the nosey out. I know it is NOT secure.

Now, I would like the user to copy modules (that I have specified) out of
the add-in vbaproject to their workbook. I have the code to copy the module
but I cannot do it if the add-in project is locked.

How do I open the add-in VBAProject, pass the password to it, then close it
again after it the copy module function is complete?

One Response:
What you are asking is considered hacking and you will not get any help here
as it is against board policy. You may have to find a different way to make
your code available to the user.


My Reply:
Okay. If it considered hacking. How do I go about sharing portions of my
code but not all of it that is contained inside my add-in without allowing
all of my code to be exposed to nosey users?

Is it still considered hacking if I know what the password is and pass it
via code to open it? For example, while researching on here, I found posts of
how to pass the password to a protected sheet to unprotect it. Is that not
the same thing?

Why is it considered hacking if I wrote the code that is protected and
placed the password protection?

If there is a better way to copy specific modules from my password-protected
(where I created and know the password) add-in to a users workbook, please
let me know.

  #3   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Programmatically Open Locked VBAProject

Just another thought,

Place the unlocking function in a module in the file you want to unlock,
then call it from your program file or your controlling file and you're done.

HTH

"XP" wrote:

Hi Michael,

Personally, I would not consider this to be hacking; but what do I know?

Unfortunately, I think the only way to do this is to use send keys (but I
could be wrong). The following function works splendidly for me. You need to
be sure that "Trust access to visual basic project" is checked in the source
file you are trying to access, and also, set a reference to "MICROSOFT VISUAL
BASIC FOR APPLICATIONS EXTENSIBILITY" for this to work.

Note that this function below unlocks the project of the current file, I
haven't tried it to unlock a different file, but it seems like you should be
able to manipulate the function to unlock the VBE in a specified file (which
may need to be activated first).

Call the function like so:

Call UnlockVBAProject(MyPassword)

Here is the function placed in a standard code module:

Private Function UnLockVBAProject(argPWD As String)
'unlock VBA project:
Dim VBP As VBProject
Set VBP = ThisWorkbook.VBProject
If VBP.Protection < vbext_pp_locked Then Exit Function
Application.ScreenUpdating = True
DoEvents
SendKeys "%{F11}%TE" & argPWD & "~~%{F11}", True
DoEvents
End Function

This may help at least to get you started.

"Michael PE" wrote:

I'd like to open a password protected VBAProject via code, copy out specific
modules, then close the project (add-in).

I have an add-in that I share with multiple functions that are used by
users. I have the add-in VBAProject password protected. This is enough to
keep the nosey out. I know it is NOT secure.

Now, I would like the user to copy modules (that I have specified) out of
the add-in vbaproject to their workbook. I have the code to copy the module
but I cannot do it if the add-in project is locked.

How do I open the add-in VBAProject, pass the password to it, then close it
again after it the copy module function is complete?

One Response:
What you are asking is considered hacking and you will not get any help here
as it is against board policy. You may have to find a different way to make
your code available to the user.


My Reply:
Okay. If it considered hacking. How do I go about sharing portions of my
code but not all of it that is contained inside my add-in without allowing
all of my code to be exposed to nosey users?

Is it still considered hacking if I know what the password is and pass it
via code to open it? For example, while researching on here, I found posts of
how to pass the password to a protected sheet to unprotect it. Is that not
the same thing?

Why is it considered hacking if I wrote the code that is protected and
placed the password protection?

If there is a better way to copy specific modules from my password-protected
(where I created and know the password) add-in to a users workbook, please
let me know.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Programmatically Open Locked VBAProject

The techniques are hacking, even if that's not YOUR intention, because they
would help anyone hack into a protected VB project.

If you have modules that you want to share, distribute them in another
unprotected project or as exported modules. This ensures that there are no
problems with SendKeys or with your modules' security (such as it is).

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Michael PE" <Michael wrote in message
...
I'd like to open a password protected VBAProject via code, copy out
specific
modules, then close the project (add-in).

I have an add-in that I share with multiple functions that are used by
users. I have the add-in VBAProject password protected. This is enough to
keep the nosey out. I know it is NOT secure.

Now, I would like the user to copy modules (that I have specified) out of
the add-in vbaproject to their workbook. I have the code to copy the
module
but I cannot do it if the add-in project is locked.

How do I open the add-in VBAProject, pass the password to it, then close
it
again after it the copy module function is complete?

One Response:
What you are asking is considered hacking and you will not get any help
here
as it is against board policy. You may have to find a different way to
make
your code available to the user.


My Reply:
Okay. If it considered hacking. How do I go about sharing portions of my
code but not all of it that is contained inside my add-in without allowing
all of my code to be exposed to nosey users?

Is it still considered hacking if I know what the password is and pass it
via code to open it? For example, while researching on here, I found posts
of
how to pass the password to a protected sheet to unprotect it. Is that not
the same thing?

Why is it considered hacking if I wrote the code that is protected and
placed the password protection?

If there is a better way to copy specific modules from my
password-protected
(where I created and know the password) add-in to a users workbook, please
let me know.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Programmatically Open Locked VBAProject

Just to add to Jon's idea...

Maybe you could create template files that contain only the procedures/functions
that you need to share. The template project's could still be protected.

Jon Peltier wrote:

The techniques are hacking, even if that's not YOUR intention, because they
would help anyone hack into a protected VB project.

If you have modules that you want to share, distribute them in another
unprotected project or as exported modules. This ensures that there are no
problems with SendKeys or with your modules' security (such as it is).

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______

"Michael PE" <Michael wrote in message
...
I'd like to open a password protected VBAProject via code, copy out
specific
modules, then close the project (add-in).

I have an add-in that I share with multiple functions that are used by
users. I have the add-in VBAProject password protected. This is enough to
keep the nosey out. I know it is NOT secure.

Now, I would like the user to copy modules (that I have specified) out of
the add-in vbaproject to their workbook. I have the code to copy the
module
but I cannot do it if the add-in project is locked.

How do I open the add-in VBAProject, pass the password to it, then close
it
again after it the copy module function is complete?

One Response:
What you are asking is considered hacking and you will not get any help
here
as it is against board policy. You may have to find a different way to
make
your code available to the user.


My Reply:
Okay. If it considered hacking. How do I go about sharing portions of my
code but not all of it that is contained inside my add-in without allowing
all of my code to be exposed to nosey users?

Is it still considered hacking if I know what the password is and pass it
via code to open it? For example, while researching on here, I found posts
of
how to pass the password to a protected sheet to unprotect it. Is that not
the same thing?

Why is it considered hacking if I wrote the code that is protected and
placed the password protection?

If there is a better way to copy specific modules from my
password-protected
(where I created and know the password) add-in to a users workbook, please
let me know.


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Programmatically Open Locked VBAProject

Dave -

Now that you mention it, that's how I handle code in one of my big projects.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Dave Peterson" wrote in message
...
Just to add to Jon's idea...

Maybe you could create template files that contain only the
procedures/functions
that you need to share. The template project's could still be protected.

Jon Peltier wrote:

The techniques are hacking, even if that's not YOUR intention, because
they
would help anyone hack into a protected VB project.

If you have modules that you want to share, distribute them in another
unprotected project or as exported modules. This ensures that there are
no
problems with SendKeys or with your modules' security (such as it is).

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______

"Michael PE" <Michael wrote in message
...
I'd like to open a password protected VBAProject via code, copy out
specific
modules, then close the project (add-in).

I have an add-in that I share with multiple functions that are used by
users. I have the add-in VBAProject password protected. This is enough
to
keep the nosey out. I know it is NOT secure.

Now, I would like the user to copy modules (that I have specified) out
of
the add-in vbaproject to their workbook. I have the code to copy the
module
but I cannot do it if the add-in project is locked.

How do I open the add-in VBAProject, pass the password to it, then
close
it
again after it the copy module function is complete?

One Response:
What you are asking is considered hacking and you will not get any help
here
as it is against board policy. You may have to find a different way to
make
your code available to the user.


My Reply:
Okay. If it considered hacking. How do I go about sharing portions of
my
code but not all of it that is contained inside my add-in without
allowing
all of my code to be exposed to nosey users?

Is it still considered hacking if I know what the password is and pass
it
via code to open it? For example, while researching on here, I found
posts
of
how to pass the password to a protected sheet to unprotect it. Is that
not
the same thing?

Why is it considered hacking if I wrote the code that is protected and
placed the password protection?

If there is a better way to copy specific modules from my
password-protected
(where I created and know the password) add-in to a users workbook,
please
let me know.


--

Dave Peterson



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
Programmatically unprotect a VBAProject Frederick Chow Excel Programming 3 March 22nd 06 08:12 AM
Locked VBAproject due to macro fault???? Simon Lloyd[_573_] Excel Programming 1 October 4th 04 07:22 PM
Locked VBAproject due to macro fault???? Simon Lloyd[_572_] Excel Programming 1 October 4th 04 09:36 AM
Locked VBAproject due to macro fault???? Simon Lloyd[_571_] Excel Programming 1 October 4th 04 09:34 AM
Test for VBAProject Locked from Viewing DennisE Excel Programming 2 January 25th 04 09:02 PM


All times are GMT +1. The time now is 10:11 PM.

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"