PDA

View Full Version : Solved: Programatic (.reg?) Macro Security Level script



JustinDevine
07-17-2006, 10:12 AM
I have what I think is a simple question. I have to distribute a form to a group of users. Their default setting on their copies of Word is HIGH macro security. Obviously this causes my VBA to do nada. I know they can change it in the options, however, sadly, this may be too difficult. Is there a way to programatically change their security level. Perhaps a .reg script or at least a way to prompt for allow even when the security is set to high. If not, I am pretty sur I am going to end up walking around changing everyones to Medium. Not appealing. Thanks!

stanl
07-17-2006, 10:38 AM
I know for Excel, the reg key is

*reg key deleted*

Stan

mdmackillop
07-17-2006, 11:55 PM
Hi Justin/Stan,
I don't know if this is possible, but I don't think it is something we should publish in open forum if it is. It seems very close to hacking, although I accept your beneficial reasons for wanting to do this.
Regards
MD

AndrewPerl
07-18-2006, 01:00 AM
The other choice would be for you to digitally sign your code. I ran into the same problem with a project where I work. I was distributing a new template to thousands of users.

My company purchased a digital certificate from VeriSign. This certificate is expressly for signing VBA code. The user will see a dialog box asking them to trust the code from XXX company. Once they accept the macros will run just fine!!!

VeriSign does go through a verification process that takes a day or two, but the digital signing worked as advertised. You can also self-sign your code, but that only works on you local machine.

One other option is if your company has a certificate server. This was not an option for me, so I did not research it.

Good luck!!!

Andrew in Kansas City

ALe
07-18-2006, 04:06 AM
how do you use reg key in vba?

uksrogers
07-18-2006, 04:45 AM
you wouldn't be able to do it from the vba code itself. You would need to put it somewhere such as a login script, so that when a user logs onto the domain the registry setting is changed.

I can verify that this works a treat as it is something we use ourselves.

stanl
07-18-2006, 06:07 AM
Hi Justin/Stan,
I don't know if this is possible, but I don't think it is something we should publish in open forum if it is. It seems very close to hacking

My apologies. The admin may delete my post and/or the entire thread.
Stan

ALe
07-18-2006, 06:17 AM
Given the fact that this script will be executed via vba (and therefore only after macro activation) I don't think it can be considered close to hacking.

Actually I'm not interested in this specific topic but I'd like to see how vba can manage reg key.

Any suggestion, link, clue?

stanl
07-18-2006, 07:32 AM
Given the fact that this script will be executed via vba (and therefore only after macro activation) I don't think it can be considered close to hacking.

I personally don't consider it hacking, but I don't want to tread on forum rules. A while back I worked in a situation where they didn't want macro code resident in Excel Workbooks, so the trust VB code was unchecked. However, I found it convenient to create macros at runtime, insert them into the VBProject, execute them and remove them before saving the workbooks. These were un-attended operations [updates, re-formats and such] so no users were involved. Prior to opening the files, I would set the registry key, then reset it back when my routines were finished.

In partial answer to your question about the registry; you can use WMI - see

http://www.windowsitpro.com/Article/ArticleID/48128/48128.html?Ad=1

Stan

ALe
07-18-2006, 07:57 AM
Thanx. I found what I was looking for also here

http://www.codeguru.com/vb/gen/vb_system/directoriesandfiles/article.php/c12067/#more

mdmackillop
07-18-2006, 09:29 AM
Given the fact that this script will be executed via vba

We are talking about publishing a script (not VBA) which will change a users security settings without their knowlege or permission, exposing them to any VBA malpractice. I'm sure it can be done, but I don't see the merits in publishing it here.

Ken Puls
07-18-2006, 10:11 AM
Hey guys,

While a very clever approach, I'm afraid that I needed to take out the key. The security features in the program are there for a reason, and it's against VBAX's policies to show how to bypass them as shown.

I do totally understand the benefits and necessities of the approach though. I'm not saying it has none, but the fact is that these posts are public. If someone PM's you on it, you can decide if their intentions are for good or for evil and act accordingly. Publicly posting loses that ability to apply discretion.

It's great work to be sure, guys. :)

stanl
07-18-2006, 01:34 PM
Thank you. Again I aplogize as my intentions were not malicious. The question becomes, should this be marked as Solved, Sorta-Solved, Could-Be-Solved:dunno

Stan

mdmackillop
07-18-2006, 01:44 PM
No apologies necessary Stan. I'll mark it solved.
Regards
MD

JustinDevine
07-20-2006, 12:30 PM
Hey how much does that cost btw?