LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Identify Load Drive

Brian,

Glad to be of any help...

You fell into an Excel Trap - when you delete rows, columns, sheets etc -
deleting # 1 makes # 2 a new # 1 (if you understand that - you have it
made). So you work from the highest number to the lowest number. Delete #
2 and than delete # 1.

To make it even easier - use a loop

Dim sh as Integer

For sh = 2 to 1 step -1
With Sheets(sh)
.visible
.select ' not sure if you need this, but I sometimes get an
error if I don't use it.
.unprotect
.delete
End With
Next

It's nice to believe this
Thanks for your help. You're right that an experienced user could
overcome
whatever I do, but then I would hope that if they're that knowledgeable
they
will appreciate the fact that it is designed to avoid them using old
information. We'll see.

but there are a lot of people out their "Without Respect".

And it really isn't necessary to delete the sheets (unless that is what you
want).

You can do the check, flash a message to the user, set a pause, and than
auto-close the workbook.

ThisWorkbook.Close False

All you can really do is protect the Good User from making unintentional
errors. That's all that Excel protection really accomplishes.

And adding a password to the VBA protects the code (this one is harder to
break). Go to the VB Editor and go to properties - there is a tab to set a
password (note that it doesn't take effect until the workbook is saved and
closed).

happy Exceling...

--
steveB

Remove "AYN" from email to respond
"Brian C" wrote in message
...
Hi Steve,

Thanks for your help. You're right that an experienced user could
overcome
whatever I do, but then I would hope that if they're that knowledgeable
they
will appreciate the fact that it is designed to avoid them using old
information. We'll see.

Here's what I'm trying to get to work. I want to unprotect 2 sheets, and
then delete them if they were loaded from the C or D drive. I think I
have
the drive ID part down and the Unprotect down, but I can't get the delete
to
work.

The code I'm using for that part is:
sDrive = Left(ThisWorkbook.Path, 1)
If UCase(sDrive) = "C" Or UCase(sDrive) = "D" Then
Application.DisplayAlerts = False
Sheets(5).Visible = True
Sheets(1).Unprotect
Sheets(2).Unprotect
Sheets(1).Delete
Sheets(2).Delete
MsgBox ("This Application Must be Launched from the RETAIL
TOOLBOX")
End If
Application.DisplayAlerts = True




 
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
Links to mapped drive change to refer to local hard drive SueD Links and Linking in Excel 1 May 8th 08 11:42 AM
Can I save to hard drive AND my flash drive at the same time? Gizelle Excel Discussion (Misc queries) 3 July 24th 06 08:27 PM
Userform Local Drive & Network drive question Joel Mills Excel Programming 3 December 29th 04 10:43 PM
Identify CD-Rom drive MD Excel Programming 5 August 24th 04 03:32 PM
Pasting a range of information from a foler on F Drive to another folder on same drive Tom Ogilvy Excel Programming 1 August 3rd 03 01:50 AM


All times are GMT +1. The time now is 10:00 PM.

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

About Us

"It's about Microsoft Excel"