Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default with sheet protection on, macro won't run to add borders around a

If protection is off, the macro runs fine. If the sheet and worksheet
becomes protected, the macro produces a runtime error 1004 that I have no
been able to locate how to fix (Visual Basic help was of no help).

The debug points to the following:
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default with sheet protection on, macro won't run to add borders around a

Dim wsh as Worksheet

Set wsh=Selection.Parent
wsh.UnProtect "Password"
<Perform things on the worksheet
wsh.Protect "Password"

Replace Password with the password of the sheet that is protected. This
password is case sensitive. If there is no password, then omit this
argument.

--
Ronald R. Dodge, Jr.
Production Statistician/Programmer
Master MOUS 2000

"Lorrie M" <Lorrie wrote in message
...
If protection is off, the macro runs fine. If the sheet and worksheet
becomes protected, the macro produces a runtime error 1004 that I have no
been able to locate how to fix (Visual Basic help was of no help).

The debug points to the following:
Selection.Borders(xlDiagonalDown).LineStyle = xlNone



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default with sheet protection on, macro won't run to add borders around a

If you protect the sheet, then just like manually, code can not change the
things that are protected.

the work around is to have your code unprotect the sheet, make the change,
reprotect the sheet or look at the UserInterfaceOnly property of the protect
methods.

--
Regards,
Tom Ogilvy


"Lorrie M" wrote:

If protection is off, the macro runs fine. If the sheet and worksheet
becomes protected, the macro produces a runtime error 1004 that I have no
been able to locate how to fix (Visual Basic help was of no help).

The debug points to the following:
Selection.Borders(xlDiagonalDown).LineStyle = xlNone

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default with sheet protection on, macro won't run to add borders around a

You can unprotect and re-protect the sheet in the macro. I would tell
you how, but I don't have Excel on the PC I'm writing this on and I
don't trust my memory to provide the correct syntax.

If you need example code and no one else offers any, reply to this and
I'll work something up. (To help with getting a solution: What version
of Excel are you using?)

Lorrie M wrote:
If protection is off, the macro runs fine. If the sheet and worksheet
becomes protected, the macro produces a runtime error 1004 that I have no
been able to locate how to fix (Visual Basic help was of no help).

The debug points to the following:
Selection.Borders(xlDiagonalDown).LineStyle = xlNone


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Data Protection Best Practice: AKA: Real Sheet Protection Mushman(Woof!)[_2_] Excel Discussion (Misc queries) 4 December 30th 09 01:20 AM
Excel Data Protection- AKA: Sheet/Macro Password Protection Mushman(Woof!) Setting up and Configuration of Excel 0 December 29th 09 06:50 AM
Can a Macro override sheet Protection? Derrick Excel Discussion (Misc queries) 6 July 24th 09 08:17 PM
Borders on Excel Sheet Laura Excel Discussion (Misc queries) 0 August 28th 07 08:20 PM
Printing Excel Sheet with borders JimLewis Excel Worksheet Functions 0 August 23rd 06 11:38 PM


All times are GMT +1. The time now is 01:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"