Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Xl2007 not unprotecting worksheet!!!!

Hi,

I'm running Win XP and both XL2003 & XL2007. I've got an application
(an .xls file, created in XL2003) with code that unprotects a
worksheet, deletes certain shapes, the reprotects the sheet. However,
in xl 2007, the code doesn't unprotect the sheet!?

here's the code:
....
shtTarget.unprotect gcstrPassword
While intZ 1
With shtTarget.Shapes(intZ)
If (.Name Like "pic_*") Then
.Delete
....more code...

To reiterate,
So this file was created in excel 2003 and runs fine, but my company
is converting to excel 2007 and one of my colleagues, who uses the
file regularly, has switched.

In XL2007, the .delete line gives me an error; so I manually
unprotected the sheet and the code runs fine, so I thought something
in the rest of my code re-protected the sheet. After creating an
error handler (shttarget.unprotect password:=gcstrpassword / resume)
to unprotect the sheet if .delete throws an error, I discovered that
the error handler infinite loops, and that's when I realized the
worksheet.unprotect doesn't actually unprotect!

I have checked with application screenupdating true and false,
enableevents true and false; there is no code that would fire to
'instantly relock' or anything like that. the password constant I'm
using (gcstrpassword) is definitely correct... I'm at a loss...

Anyone have any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Xl2007 not unprotecting worksheet!!!!

do a check with just this one line

shtTarget.unprotect gcstrPassword

if it fails - and your comments suggest that it will, record a macro to
unprotect the sheet to see if it differs

as far i can tell though, syntax is correct . but it is case dependent


"Mike" wrote in message
...
Hi,

I'm running Win XP and both XL2003 & XL2007. I've got an application
(an .xls file, created in XL2003) with code that unprotects a
worksheet, deletes certain shapes, the reprotects the sheet. However,
in xl 2007, the code doesn't unprotect the sheet!?

here's the code:
...
shtTarget.unprotect gcstrPassword
While intZ 1
With shtTarget.Shapes(intZ)
If (.Name Like "pic_*") Then
.Delete
...more code...

To reiterate,
So this file was created in excel 2003 and runs fine, but my company
is converting to excel 2007 and one of my colleagues, who uses the
file regularly, has switched.

In XL2007, the .delete line gives me an error; so I manually
unprotected the sheet and the code runs fine, so I thought something
in the rest of my code re-protected the sheet. After creating an
error handler (shttarget.unprotect password:=gcstrpassword / resume)
to unprotect the sheet if .delete throws an error, I discovered that
the error handler infinite loops, and that's when I realized the
worksheet.unprotect doesn't actually unprotect!

I have checked with application screenupdating true and false,
enableevents true and false; there is no code that would fire to
'instantly relock' or anything like that. the password constant I'm
using (gcstrpassword) is definitely correct... I'm at a loss...

Anyone have any suggestions?


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
Unprotecting a worksheet Jessica Excel Worksheet Functions 8 August 21st 08 06:43 PM
Protecting & Unprotecting worksheet Tammy H Excel Programming 3 September 19th 07 12:58 AM
Unprotecting a Worksheet Anney Excel Worksheet Functions 7 August 4th 07 01:14 PM
unprotecting my worksheet DowningDevelopments Excel Programming 4 October 9th 06 06:38 PM
unprotecting a worksheet Randy123 Excel Discussion (Misc queries) 1 August 8th 05 06:11 PM


All times are GMT +1. The time now is 05:16 PM.

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"