close

i have an excel document, that works fine and produces another file
based on the template.

On open of the original document, i have a macro to go and clear any
data in particular cells.

When creating the new file, in my macro I have set the new workbook to
be protected; however when this file is open, it goes and runs the
clear function. This gives an error as it can not clear the cells
due to the protection.

I dont want to turn the protection off, so is there anyway I can check
for protection, if protection is found, then dont run the clear code,

Thanks.--
mdma
------------------------------------------------------------------------
mdma's Profile: www.excelforum.com/member.php...oamp;userid=24284
View this thread: www.excelforum.com/showthread...hreadid=536786Hi mdma,

You could try something like:
If ActiveSheet.ProtectContents = True Then Exit Sub
or
If ActiveSheet.ProtectContents = False Then
' the rest of your clearing code goes here
End If

Cheersquot;mdmaquot; gt; wrote in message
...
gt;
gt; i have an excel document, that works fine and produces another file
gt; based on the template.
gt;
gt; On open of the original document, i have a macro to go and clear any
gt; data in particular cells.
gt;
gt; When creating the new file, in my macro I have set the new workbook to
gt; be protected; however when this file is open, it goes and runs the
gt; clear function. This gives an error as it can not clear the cells
gt; due to the protection.
gt;
gt; I dont want to turn the protection off, so is there anyway I can check
gt; for protection, if protection is found, then dont run the clear code,
gt;
gt; Thanks.
gt;
gt;
gt; --
gt; mdma
gt; ------------------------------------------------------------------------
gt; mdma's Profile:
www.excelforum.com/member.php...oamp;userid=24284
gt; View this thread: www.excelforum.com/showthread...hreadid=536786
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()