Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Vic
 
Posts: n/a
Default Applying Existing Password to New Spreadsheet

I have developed a personal tracking spreadsheet that I
occasionally send out an up-dated version to those using
it. The spreadsheet will automatically up-date the data
into the new version and save it under the same name. The
user simply clicks a data transfer button and is given the
opportunity to open the existing spreadsheet and transfer
the data to the new version. The problem is that I don't
know how to capture the password to include that in the
new up-dated spreadsheet so that the user doesn't have to
re-enter the password during the first save after the up-
date. Is it possible to capture the password of the
opened spreadsheet and save the new version with the same
password? Any help would be appreciated. Thanks!

  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

How do you unprotect the worksheet?

If you let the user do it manually, you can't capture it.

If you use code to display that unprotect dialog, you can't capture it.

But you could use an inputbox (or userform to mask the password) and ask the
user for it.

Then have your code unprotect, do its stuff and then reprotect.

Kind of...

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim myPwd As String
Dim SheetWasProtected As Boolean

Set wks = Worksheets("sheet1")

With wks
SheetWasProtected = False
If .ProtectContents _
Or .ProtectDrawingObjects _
Or .ProtectScenarios Then
SheetWasProtected = True
myPwd = InputBox(Prompt:="what's the passwork, kenny?")
On Error Resume Next
.Unprotect Password:=myPwd
If Err.Number < 0 Then
MsgBox "Wrong password, try later!"
Err.Clear
Exit Sub
End If
On Error GoTo 0

'do your stuff

If SheetWasProtected Then
.Protect Password:=myPwd
End If
End If
End With
End Sub



Vic wrote:

I have developed a personal tracking spreadsheet that I
occasionally send out an up-dated version to those using
it. The spreadsheet will automatically up-date the data
into the new version and save it under the same name. The
user simply clicks a data transfer button and is given the
opportunity to open the existing spreadsheet and transfer
the data to the new version. The problem is that I don't
know how to capture the password to include that in the
new up-dated spreadsheet so that the user doesn't have to
re-enter the password during the first save after the up-
date. Is it possible to capture the password of the
opened spreadsheet and save the new version with the same
password? Any help would be appreciated. Thanks!


--

Dave Peterson
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
Password cannot be removed twa14 Excel Discussion (Misc queries) 3 December 14th 04 12:27 PM
password protect a spreadsheet to prevent it from being opened. spongebobvan Excel Worksheet Functions 2 November 23rd 04 09:12 PM
How do I password protect cells in a spreadsheet created in Excel Tbenson37303 Excel Worksheet Functions 0 November 22nd 04 10:21 PM
How do I password protect cells in a spreadsheet created in Excel [email protected] Excel Worksheet Functions 0 November 22nd 04 10:21 PM
Creating a summary from existing spreadsheet data ... NP Excel Worksheet Functions 8 October 29th 04 02:39 PM


All times are GMT +1. The time now is 06:18 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"