• BeforeClose is not activating sheets (2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » BeforeClose is not activating sheets (2003)

    Author
    Topic
    #435402

    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

    Viewing 0 reply threads
    Author
    Replies
    • #1028941

      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 bwaaah

      Why is the code not working????

      Thanks in advance for your reaction.
      Patrick Schouten

      • #1028951

        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

        • #1028953

          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

    Viewing 0 reply threads
    Reply To: BeforeClose is not activating sheets (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: