Results 1 to 4 of 4
  1. #1
    3 Star Lounger siflaar's Avatar
    Join Date
    Jan 2001
    Location
    Amersfoort, Netherlands
    Posts
    203
    Thanks
    4
    Thanked 0 Times in 0 Posts

    BeforeClose is not activating sheets (2003)

    Hello all,

    I have a workbook_BeforeClose procedure running in the ThisWorkbook area
    This procedure must unprotect a sheet, change two cells and protect it again, but it is not working.
    Even activating, selecting, making the sheet visible is not working.
    I call other procedures which normaly work to activate one of my sheets, but no other sheets than the current one is shown or can be edited from the code called within the BeforeClose prcedure.
    Is this normal?

    I hope someone can help me out here.

    greetings,
    Patrick Schouten
    Meander Medisch Centrum
    Greetings,

    Patrick Schouten
    (The Netherlands)

  2. #2
    3 Star Lounger siflaar's Avatar
    Join Date
    Jan 2001
    Location
    Amersfoort, Netherlands
    Posts
    203
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: BeforeClose is not activating sheets (2003)

    extra info:

    Well if the code is not showing the correct sheet, that is no so bad, I can live with it.
    But the strange thing is that I can not unprotect the sheet by code

    Sheets("Personeel").Unprotect Password:=strWW

    the programm is running this line, giving me no error and on the next line:

    Range("P1").Value = "aangepast"

    (this time a manuly made shure the active sheet is the correct one) Excel is giving me a 1004 error telling me that the cell is protected.
    In de VBA editor I print the value of strWW, copy it and manuely unprotect the sheet, by pasting the strWW value... it works <img src=/S/bwaaah.gif border=0 alt=bwaaah width=123 height=15>

    Why is the code not working????

    Thanks in advance for your reaction.
    Patrick Schouten
    Greetings,

    Patrick Schouten
    (The Netherlands)

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: BeforeClose is not activating sheets (2003)

    Could you post your code (it is tough to troubleshoot when you do not post your code) or a sample workbook that displays the problem?

    One comment:
    Range("P1").Value = "aangepast"

    always refers to the activesheet since you do not explicitly give a sheetname.

    If "personneel" may not be the activesheet you should use:
    Sheets("Personeel").Range("P1").Value = "aangepast"

    since it will not matter than what the activesheet is.

    Steve

  4. #4
    3 Star Lounger siflaar's Avatar
    Join Date
    Jan 2001
    Location
    Amersfoort, Netherlands
    Posts
    203
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: BeforeClose is not activating sheets (2003)

    Steve,

    Thanks for the reply.
    I have made sure "Personeel" is the active sheet, I also tried your code line, it does not work
    I will prepare a examplesheet tomorrow and post it
    Greetings,

    Patrick Schouten
    (The Netherlands)

Posting Permissions

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