Public Function sometimes runs, sometimes not RRS feed

  • Question

  • The Sub Auto_Open() calls analyse_bugs. Now, sometimes it does, sometimes not. Originally, I just wrote 'analyse_bugs', but suddenly it stopped actually calling the function. Then I put a breakpoint in the code, and then it decided to actually run it. I then put in the 'Call' statement and then it did call the function without me putting a breakpoint. Then after that it decided after all NOT to call the function. Never experienced this before, it is like my code has ghosts in it.

    I tried deleting the calling code, typing it in again, that seems to work first time round, then next time it runs it forgets to do the job.

    Please explain!

    BW Peter Bunde Hansen

    Sub Auto_Open()

        Application.WindowState = xlNormal
        Application.Left = 7
        Application.Top = 605.5
        Application.Width = 723
        Application.Height = 296.25
        Application.Left = 274
        Application.Top = 277

        Application.DisplayAlerts = False
        clear_report 'ren tavle
        windows_userinfo 'hent info fra LDAP om den bruger som er logget ind
        SQLnumber = 1
        FillSheet = "Test plan og rapport"
        Sheet_ ("Test plan og rapport")
        define_devboard 'hent info fra JIRA om det board som er angivet i settings som værende udviklingdboard
        define_defectboard 'hent info fra JIRA om det board som er angivet i settings som værende defectboard (ofte det samme som udviklingsboard)
        define_sprint 'indlæs start og slutdato for sprintet, det kan være to, tre eller flere uger langt, fx et accepttest sprint
        Call analyse_bugs
        column_type = "border"
        Call insertcolumn_leftto("bugid", "space1")
        placeboardleftto = "bugid"
        activecolumn = "C"
        activecolumn = "D"
        column_type = "space"
        Call insertcolumn_leftto("testname", "space2")
        placeboardleftto = "testname"
        Application.WindowState = xlMaximized
        Application.DisplayAlerts = True
        Application.WindowState = xlMaximized
    '    SQLnumber = 2
    '    FillSheet = "Testressourcer"
    '    ALMquery
    '    FillReqset
    End Sub

    Wednesday, September 7, 2016 5:56 PM

All replies

  • Hi,

    This is the forum to discuss questions and feedback for Microsoft Excel, I'll move your question to the MSDN forum for Excel

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Emi Zhang
    TechNet Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact

    Thursday, September 8, 2016 9:17 AM
  • Hi Emi

    When I follow your link, I get back to here. I am confused as to where you have moved me?

    BW Peter Bunde Hansen

    Thursday, September 8, 2016 9:50 AM
  • Hi PeterBHansen,

    According to your description, I suggest that you could try the code below to see if the problem persists.
    Sub Demo()
        ActiveWorkbook.RunAutoMacros xlAutoOpen
    End Sub
    or you could copy VBA code for the Open event of a workbook, then delete Auto_Open macro, what is the result?

    For more information, please refer to Run an Excel macro

    Thanks for your understanding.
    Friday, September 9, 2016 8:12 AM
  • I preffer  workbook_open event over auto_open.

    For some reasons it works better for me.

    Wednesday, September 14, 2016 12:31 PM