Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / April 2007

Tip: Looking for answers? Try searching our database.

Force users to enable macros when open a workbook

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tan - 15 Apr 2007 14:44 GMT
Hi All,

I have wrote a program for reporting dashboard and faces 2 issues. One is
end users macros security is set at high level. Second issue is end users
disable macros. How do i force end users to enable my macros if any of the
above occurs?

Can anyone advice me how do i add the extra codes to make this happen. My
codes stored in My Workbook as follows:

Private Sub Workbook_Open()
   Call Login
   MsgBox "Last Updated on Wednesday, February 28, 2007.", vbInformation
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
   Call DeleteMenu
End Sub

Thanks in advance...
Dave Peterson - 15 Apr 2007 15:54 GMT
There's nothing you can do in the workbook that will force the user to open with
macros enabled.  (If macros are disabled, then none of your code will work.)

You could create a workbook that opens the real workbook.  In this helper
workbook, you have one visible sheet--it contains "Please open this file with
macros enabled".  If the user doesn't enable macros, then the real workbook
won't be opened.

If macros are enabled, then the first workbook opens the second (with macros
enabled), and closes itself.

Option Explicit
Sub auto_open()

   Dim myPWD As String
   Dim wkbk As Workbook
   myPWD = "hi"
   Set wkbk = Workbooks.Open(Filename:="C:\my documents\excel\book1.xls", _
                  Password:=myPWD)
   
   wkbk.RunAutoMacros which:=xlAutoOpen
   
   'ThisWorkbook.Close savechanges:=False

End Sub

When you're done testing, uncomment that last line.  It closes the helper
workbook without saving--could be a pain while you're testing.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

> Hi All,
>
[quoted text clipped - 16 lines]
>
> Thanks in advance...

Signature

Dave Peterson

Stan Brown - 15 Apr 2007 17:09 GMT
Sun, 15 Apr 2007 06:44:04 -0700 from Tan
<Tan@discussions.microsoft.com>:
> I have wrote a program for reporting dashboard and faces 2 issues. One is
> end users macros security is set at high level. Second issue is end users
> disable macros. How do i force end users to enable my macros if any of the
> above occurs?

Unless you can fund and exploit an Excel security flaw, there's no
way. This the whole point of setting the macro security level, after
all. It would be pretty useless if a workbook could contain an
unsigned macro that ran despite the user setting security to High.

So you can't "force" users to run your macros. If your workbook is
something that they need, when you distribute it you can let them
know that they'll need to set macro security to Medium and then click
the Enable Macros button on the prompt.

If this is too inconvenient, you can purchase a digital signature.
Then your users will be able to select "always trust macros from this
publisher" once and never again see the macro warning. (This is how
most commercial add-ins are distributed, if they contain macros.)

Signature

Stan Brown, Oak Road Systems, Tompkins County, New York, USA
                                 http://OakRoadSystems.com/


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.