![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
Can anybody help me to solve some problems in VBA.
1. to remove a module(Macros included) in tens of workbooks 2. to modify some contents of the a module(modify the codes) 3. to force user to enable Macro. If user disable Macro, nothing will be shown. I found one of the program from internet. But it is just two Subs ShowAll() and HideAll(). I don't know how the codes extract the user's response "enable Macros" or "disable macros". Thx |
|
|
|
#2 |
|
New Member
Join Date: Feb 2002
Location: ]-[ /-\ \/\/ /-\ | | ~~~@|_()]-[/-\!!!
Posts: 48
|
|
|
|
|
|
|
#3 |
|
Guest
Posts: n/a
|
Sorry--regarding question 3: I forgot where the link was for a work-around--(btw, there is no straight-forward solution, as this is a security measure to prevent malicious vba code from running without the user's intervention.) In XL9 and above, there is a menu command (macro security) that enables you to select low setting which disables the macro warning altogether. But this is risky and also, the user can change to medium or high at any time. The work-around I read about (sorry, forgot where) suggested the following (loosely translated):
*create a dummy (blank) workbook. *open vbe and add vba code to 'thisworkbook' object (e.g.) Private Sub Workbook_Open() Workbooks.Open FileName:="C:My DocumentsMyWorkbook.xls", password:="MyPassword" ThisWorkbook.Close savechanges:=False End Sub *save and password protect this workbook and the vba project also. *The workbook you just created will open the main document you want to protect from user intervention. Now... *open the workbook you are trying to control user intervention (MyWorkbook.xls in the example) and add the following code to 'thisworkbook' object Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, cancel As Boolean) If SaveAsUI Then cancel = True End If End Sub *password protect the vba project and also the workbook (use a different password from the dummy workbook--replace "MyPassword" in example above with password you use to open this workbook). So now, you have your users open the "dummy" workbook (with a password you provide) which in turn, opens the main document. If they cancel macros, it doesn't open the main workbook, but there is nothing in the dummy workbook for them to snoop about, and they can't view your code because you have protected it. If they enable macros, the dummy workbook will then open the main workbook and launch the macros without the confirmation, then close itself. The password protection for the main document is in case someone happens to try to open it bypassing the dummy workbook. The 'beforesave' macro code is to prevent the user from using the "save as" command to save an unprotected copy for themselves to snoop about. Whew! it sure would have been faster to just paste the link here instead of this long reply!!! Aloha! |
|
|
|
#4 |
|
New Member
Join Date: Feb 2002
Location: ]-[ /-\ \/\/ /-\ | | ~~~@|_()]-[/-\!!!
Posts: 48
|
(above message from me)
Rats, got booted out yet again! WDD! |
|
|
|
|
|
#5 |
|
Guest
Posts: n/a
|
Thank you very much for so detailed explanation!!! i really appreciate it. Also i find that the website you suggested is great!!
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|