PDA

View Full Version : Programmatically Open Locked VBAProject



MrRhodes2004
01-02-2008, 09:24 AM
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?

lucas
01-02-2008, 10:03 AM
Hi MrRhodes,
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.

MrRhodes2004
01-02-2008, 10:12 AM
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.

lucas
01-02-2008, 10:24 AM
I'm sorry if I offended you. I did not mean to imply that you were doing anything wrong...only that by discussing it the potential for abuse by others should be obvious.

MrRhodes2004
01-02-2008, 10:30 AM
No offense taken at all.

But you say that I should not do it that way is it would be considered hacking. That is fine but what are your suggestions to share portions of my code without exposing all my other code without sharing the secrets of hacking or it considered to be hacking?

Bob Phillips
01-02-2008, 10:36 AM
This is not hacking, it won't work without the password, but it is unstable


This is an example, but you may need to tune it



With Application
.SendKeys "%{F11}", True ' VBE
.SendKeys "^r", True ' Set focus to Explorer
.SendKeys "{TAB}", True ' Tab to locked project
.SendKeys "~", True ' Enter
.SendKeys "password"
.SendKeys "~", True ' Enter
End With

Bob Phillips
01-02-2008, 11:03 AM
So MrRhodes2004 is Michael PE!

MrRhodes2004
01-02-2008, 11:20 AM
So MrRhodes2004 is Michael PE!

Yes, that is correct. Is that other site any good? One of the links that I found took me there so I thought I would post to it was well.

If there are better ways to accomplish what I am trying to do with my code, then I would like to explore those routes.

I share my add-in via the network and only have it password protected to make sure that it isn't mistakenly changed. But now, since we are using ProjectWise as a management tool, the add-in has become an issue. Each time one of the functions in the add-in is used, ProjectWise thinks that the add-in is part of the project and tries to copy it into the project folder.

So now, I am going to allow the user to copy the certain code from my add-in to their workbook. But I still do not want them to have access to the full code of the add-in.

Is there a better way to do this instead of opening the locked project?

MrRhodes2004
01-02-2008, 12:16 PM
How about this:

If I copy out from the shared add-in the functions to one .bas file that is available on the network.

Then using the add-in, have a button that the user could press to import the module into their workbook.

Is this a better way of doing what I need to do? Or is this still considered a form of hacking? Or, is what I am trying to accomplish just poor programming? If so, what would be a better approach?

lucas
01-02-2008, 12:27 PM
I guess my first question would be....why do they need to copy the code if it is already available to them in the addin?

MrRhodes2004
01-02-2008, 01:28 PM
I guess my first question would be....why do they need to copy the code if it is already available to them in the addin?

Good question. The problem was created with the use of ProjectWise file management software. All of our project files are located within the PW system including Excel documents. PW, a Bentley Systems product originally created for Microstation file management, tries to manage all the files of a project. While updating an Excel document, it reads the files to locate all associated or linked documents then tries to copy those documents into the project folder. In doing so, it thinks that the add-in is a linked file and tries to copy the add-in to the project directory. When it does this, excel tries to update the links which creates a mess.

Before PW:
=UDF(C4)

After PW:
=\\daxxserver\xyzfolder\abcfolder\dfgfolder\UDF(C4)

This creates a problem when several user defined functions are included in a calculation.

The purpose of PW is to ensure that all of the files for a project are maintained and able to be archived. PW sees the UDFs as a linked item and not as a function like Sum(), Average(), or Now().

What I am trying to do is create a work around for the problem by using an add-in with PW. In turn I may be causing other problems. I think or PW gurus are advanced Microstation users and therefore do not know a great deal about Excel. In addition, I have not found anyone who uses both excel add-ins and PW.

I hope this explains my situation a little bit more. If not, let me know and I will try to expand.

Thanks again for trying to understand my problem and trying to help. It is appreciated.

Bob Phillips
01-02-2008, 02:51 PM
Just a thought.

Dump ProjectWise?

Rewrite your addins in VB?

Bob Phillips
01-02-2008, 02:53 PM
BTW, the other place is my main hangout, and it isn't good, it is great. Better even than VBAX, although this is probably a better place to develop a project over time, as it is smaller, less intense, and we tend to remember the past issues better over here.

asingh
01-02-2008, 04:59 PM
BTW, the other place is my main hangout

XLD...what is this other place...care to share..want to check it out...!

:)

regards,

asingh

Bob Phillips
01-03-2008, 02:25 AM
I am referring to the Microsoft public newsgroups, where MrRhodes2004 sought further help ... I caught him in the act <bg>