Selasa, 19 Juli 2011

[ExcelVBA] Re: force users to enable macros

 


In your BeforeClose event, you have not actually saved the worksheet visibility that you want. Use ThisWorkbook.Save rather then ThisWorkbook.Saved = True.

Dave Gathmann

--- In ExcelVBA@yahoogroups.com, "Saad" <saad.saadusman@...> wrote:
>
> Dear experts:
>
> I have a workbook with 3 worksheets
>
> 1. warning
> 2. A
> 3. B
>
> In the sheet 'warning', there is a simple message that "Please enable macros to work with this workbook."
>
> In sheets A and B, i have some data and analayses to display.
>
> I would like that when a user chooses to disable macros, he should be directed to the warning sheet only. The other sheets should be 'veryhidden'.
>
> When the user enables macros, the warning sheet should then be 'veryhidden' and other two sheets be displayed.
>
> I wrote following code:
>
> Private Sub Workbook_BeforeClose(Cancel As Boolean)
> Sheets("warning").Visible = True
> Sheets("A").Visible = xlSheetVeryHidden
> Sheets("B").Visible = xlSheetVeryHidden
> Application.ThisWorkbook.Saved = True
> End Sub
>
> Private Sub Workbook_Open()
> Sheets("A").Visible = True
> Sheets("B").Visible = True
> Sheets("warning").Visible = xlSheetVeryHidden
> End Sub
>
> The problem is that first time, the code works well. However, next time, it always hides the warning sheet and shows the other sheets, whether or not the macros are enabled.
>
> Need help on this one! I am using Excel 2010.
>
> Best regards, Saad
>

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar