Results 1 to 5 of 5
  1. #1
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Access automation to excel locking/unlocking (Access 2003 SP2)

    Can i unlock cells if they have been previously locked?

    I use an excel sheet as a template, i copy it to another file and use automation on that.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access automation to excel locking/unlocking (Access 2003 SP2)

    Let's say obj is an Excel.Worksheet object. You can then use

    obj.Unprotect
    obj.Range("A1:E3").Locked = False
    obj.Protect

  3. #3
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Access automation to excel locking/unlocking (Access 2003 SP2)

    Do you need protect/unprotect before unlocking?

    Does that mean i can unprotect the sheet before doing a whole lot of populating cells and protect it before i close it?

    Whats a good reference to learn automation of excel?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access automation to excel locking/unlocking (Access 2003 SP2)

    You cannot modify the Locked property of cells while the sheet is protected the normal way (using Tools | Protection | Protect Sheet...). If you protect a sheet using code, you can specify that it only affects the user interface, not Visual Basic code:

    obj.Protect UserInterfaceOnly:=True

    So normally you have to unprotecy the sheet, manipulate the Locked property, then protect the sheet again.

    Automating Excel means that you use Excel VBA code from Access. So to learn automating Excel, you have to learn Excel VBA. John Walkenbach has good books about Excel, see Excel Books by John Walkenbach.

    See Automation 101 by our moderator WendellB for a general introduction and useful links.

  5. #5
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Access automation to excel locking/unlocking (Access 2003 SP2)

    Thanks Hans, i will look up those references.

    I will test the unprotect unlock logic today hopefully.

Posting Permissions

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