+ Reply to Thread
Results 1 to 2 of 2

Applying Existing Password to New Spreadsheet

  1. #1
    Vic
    Guest

    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. #2
    Dave Peterson
    Guest

    Re: Applying Existing Password to New Spreadsheet

    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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1