+ Reply to Thread
Results 1 to 3 of 3

Unprotect sheet when printing

  1. #1
    bbc1
    Guest

    Unprotect sheet when printing

    Have the below code to print a sheet, increment a invoice number and remove
    protection from sheet, at the moment the passowrd is nothing I nee to change
    this to qwert and edit the formula to up protect sheet on print and re
    protect it after the incrementing of the invoice number. Any help would be
    appreaciated.

    Sub dayprint()
    '
    ' dayprint Macro
    '
    '

    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    Sheet13.Unprotect
    'Increment the invoice number
    [e3] = [e3] + 1
    Sheet13.Protect

    ' Save Macro
    ' Macro recorded 19/08/2005
    '
    '
    ActiveWorkbook.Save
    End Sub

  2. #2
    Norman Jones
    Guest

    Re: Unprotect sheet when printing

    Hi BBC1,

    Try something like:

    Sub dayprint()
    Const PWORD As String = "qwert"

    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    With ThisWorkbook.Sheets("Sheet13")
    .Unprotect Password:=PWORD
    'Increment the invoice number
    With .Range("E3")
    .Value = .Value + 1
    End With
    .Protect Password:=PWORD
    End With

    ActiveWorkbook.Save
    End Sub


    ---
    Regards,
    Norman



    "bbc1" <[email protected]> wrote in message
    news:[email protected]...
    > Have the below code to print a sheet, increment a invoice number and
    > remove
    > protection from sheet, at the moment the passowrd is nothing I nee to
    > change
    > this to qwert and edit the formula to up protect sheet on print and re
    > protect it after the incrementing of the invoice number. Any help would be
    > appreaciated.
    >
    > Sub dayprint()
    > '
    > ' dayprint Macro
    > '
    > '
    >
    > ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    > Sheet13.Unprotect
    > 'Increment the invoice number
    > [e3] = [e3] + 1
    > Sheet13.Protect
    >
    > ' Save Macro
    > ' Macro recorded 19/08/2005
    > '
    > '
    > ActiveWorkbook.Save
    > End Sub




  3. #3
    bbc1
    Guest

    Re: Unprotect sheet when printing

    Thankyou works great.

    "Norman Jones" wrote:

    > Hi BBC1,
    >
    > Try something like:
    >
    > Sub dayprint()
    > Const PWORD As String = "qwert"
    >
    > ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    > With ThisWorkbook.Sheets("Sheet13")
    > .Unprotect Password:=PWORD
    > 'Increment the invoice number
    > With .Range("E3")
    > .Value = .Value + 1
    > End With
    > .Protect Password:=PWORD
    > End With
    >
    > ActiveWorkbook.Save
    > End Sub
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "bbc1" <[email protected]> wrote in message
    > news:[email protected]...
    > > Have the below code to print a sheet, increment a invoice number and
    > > remove
    > > protection from sheet, at the moment the passowrd is nothing I nee to
    > > change
    > > this to qwert and edit the formula to up protect sheet on print and re
    > > protect it after the incrementing of the invoice number. Any help would be
    > > appreaciated.
    > >
    > > Sub dayprint()
    > > '
    > > ' dayprint Macro
    > > '
    > > '
    > >
    > > ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    > > Sheet13.Unprotect
    > > 'Increment the invoice number
    > > [e3] = [e3] + 1
    > > Sheet13.Protect
    > >
    > > ' Save Macro
    > > ' Macro recorded 19/08/2005
    > > '
    > > '
    > > ActiveWorkbook.Save
    > > End Sub

    >
    >
    >


+ 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