+ Reply to Thread
Results 1 to 5 of 5

Unprotect Sheet Password in Macros

  1. #1
    Theresa
    Guest

    Unprotect Sheet Password in Macros

    Hi:

    I have an Excel file that has been used as a template to create 800+ files
    that has the protection worksheet applied. I now what to add more formulas
    to this file and want to use a macro to do it. How can I enter the unprotect
    password automaticcaly as part of the macro and then protect the sheet again
    before saving and closing?

    Thanks

  2. #2
    Jim Thomlinson
    Guest

    RE: Unprotect Sheet Password in Macros

    public const MYPASSWORD as string = "supersecret" 'At the top of a module

    Sub Stuff()
    sheets("Sheet1").unprotect MYPASSWORD
    'Do your stuff
    sheets("Sheet1").protect MYPASSWORD
    End Sub
    --
    HTH...

    Jim Thomlinson


    "Theresa" wrote:

    > Hi:
    >
    > I have an Excel file that has been used as a template to create 800+ files
    > that has the protection worksheet applied. I now what to add more formulas
    > to this file and want to use a macro to do it. How can I enter the unprotect
    > password automaticcaly as part of the macro and then protect the sheet again
    > before saving and closing?
    >
    > Thanks


  3. #3
    sebastienm
    Guest

    RE: Unprotect Sheet Password in Macros

    To unprotect a worksheet, assuming the book is already open:
    Dim Wsh as worksheet
    set wsh= activeworkbook.Worksheets(1) 'Eg: for 1 sheet of active book

    wsh.unprotect "your_password"
    '... do what you have to do here
    'then reprotect with wsh.protect .....

    (If you meant to unprotect a protected vba project, not the sheet, then it
    is not possible through code)

    --
    Regards,
    Sébastien
    <http://www.ondemandanalysis.com>


    "Theresa" wrote:

    > Hi:
    >
    > I have an Excel file that has been used as a template to create 800+ files
    > that has the protection worksheet applied. I now what to add more formulas
    > to this file and want to use a macro to do it. How can I enter the unprotect
    > password automaticcaly as part of the macro and then protect the sheet again
    > before saving and closing?
    >
    > Thanks


  4. #4
    Tom Ogilvy
    Guest

    Re: Unprotect Sheet Password in Macros

    Activesheet.Unprotect Password:="ABC"


    ActiveSheet.Protect Password:="ABC"
    ActiveWorkbook.Close Savechanges:=True

    --
    Regards,
    Tom Ogilvy

    "Theresa" <[email protected]> wrote in message
    news:[email protected]...
    > Hi:
    >
    > I have an Excel file that has been used as a template to create 800+ files
    > that has the protection worksheet applied. I now what to add more

    formulas
    > to this file and want to use a macro to do it. How can I enter the

    unprotect
    > password automaticcaly as part of the macro and then protect the sheet

    again
    > before saving and closing?
    >
    > Thanks




  5. #5
    zuhair
    Guest

    RE: Unprotect Sheet Password in Macros

    Sir,
    I have a web site showing stock prices. By marking the rows and linking to
    excel comand, sheet1 is linked and the data changing in the web is reflected
    in sheet1. the problem is that in Worksheet_Change sub is not getting
    activated although if I key in a number tha event is happening. any help.

    code bellow

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)

    k = 1
    Application.EnableEvents = False
    SheetName = Worksheets("Sheet1").Cells(Target.Row, 2)

    Do While Worksheets("Sheet1").Cells(Target.Row, k) <> ""
    Worksheets(SheetName).Cells(SheetsLastRow(Target.Row), k) =
    Worksheets("Sheet1").Cells(Target.Row, k)
    k = k + 1
    Loop

    Worksheets(SheetName).Cells(SheetsLastRow(Target.Row), k) = Time

    If Target.Column = 3 Then
    Call CheckThePrice(Target.Row)

    End If

    SheetsLastRow(Target.Row) = SheetsLastRow(Target.Row) + 1

    Application.EnableEvents = True

    End Sub


    this code does what is suppose to do if manualy we chang the cell value then
    hit enter. but not when the value is changed by link to the web site.

    please email me.

    thank you.
    [email protected]

    "sebastienm" wrote:

    > To unprotect a worksheet, assuming the book is already open:
    > Dim Wsh as worksheet
    > set wsh= activeworkbook.Worksheets(1) 'Eg: for 1 sheet of active book
    >
    > wsh.unprotect "your_password"
    > '... do what you have to do here
    > 'then reprotect with wsh.protect .....
    >
    > (If you meant to unprotect a protected vba project, not the sheet, then it
    > is not possible through code)
    >
    > --
    > Regards,
    > Sébastien
    > <http://www.ondemandanalysis.com>
    >
    >
    > "Theresa" wrote:
    >
    > > Hi:
    > >
    > > I have an Excel file that has been used as a template to create 800+ files
    > > that has the protection worksheet applied. I now what to add more formulas
    > > to this file and want to use a macro to do it. How can I enter the unprotect
    > > password automaticcaly as part of the macro and then protect the sheet again
    > > before saving and closing?
    > >
    > > Thanks


+ 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