Announcement

Collapse
No announcement yet.

Unconfigured Ad Widget

Collapse

"can't enter break mode at this time" error with VBA References

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • "can't enter break mode at this time" error with VBA References

    Hi folks. I've just realized that I had originally posted in the wrong subforum so maybe that's why my question wasn't being answered

    further to my thread over here, I would like to know how to resolve the "can't enter break mode at this time" error.

    Basically, I'm trying to add/remove an Outlook Reference in my vba code but everytime I get to the part of my code that adds or removes the Reference, I get the "can't enter break mode at this time" error.

    I'm using this code
    Code:
    Sub TestOutlookReference()
    Dim obj As Object
    Dim sFind As Boolean
    Application.DisplayAlerts = False
            For Each obj In ThisWorkbook.VBProject.References
                If obj.Name = "Outlook" Then
                    ThisWorkbook.VBProject.References.Remove obj
                   ' .References.Remove obj
                    ThisWorkbook.VBProject.References.AddFromFile Application.Path & "\msoutl.olb"
                    sFind = True
                    Exit For
                End If
            Next obj
     If sFind = False Then ThisWorkbook.VBProject.References.AddFromFile "C:\Program Files\Microsoft Office\OFFICE14\msoutl.olb"
     Application.DisplayAlerts = True
    End Sub
    I've hightlighted the lines where I get the error.

    As a note... the code does add/remove the Outlook Reference but the macro stops running after this error comes up.

    Have looked all over the web but can't seem to find any resolution to this issue I have also tried adding the reference using the GUID but I still get the same error.

    Would appreciate any/all help resoving this.

    Thanks in advance

  • #2
    Re: "can't enter break mode at this time" error with VBA References

    *Edit* Removed - misunderstood the question

    Comment


    • #3
      Re: "can't enter break mode at this time" error with VBA References

      Are you stepping through the code, or running it? Stepping through it won't work (and you would get that error) but running it should.
      Rory
      Theory is when you know something, but it doesnít work. Practice is when something works, but you donít know why. Programmers combine theory and practice: nothing works and they donít know why

      Comment


      • #4
        Re: "can't enter break mode at this time" error with VBA References

        D'oh!

        That was pretty silly of me.

        Thanks Rory, running the code (not debugging it) works flawlessly.

        Edit:

        Oops looks like I jumped the gun

        I've copied the code to my working file and I still get the same error (regardless of whether I step through the code or F5 it.)

        The workbook is meant to open other files and load a form. But since I added the code to check references the files open but form doesn't load anymore. It doesn't give any other error messages or anything

        Any clue how to fix that? Any breakpoints that I put in after the TestReferences code seems to get ignored as the code still goes to the file opening module
        Last edited by iLurk; April 12th, 2011, 13:23.

        Comment


        • #5
          Re: "can't enter break mode at this time" error with VBA References

          Time for you to upload an anonymous, sample workbook then - Rory's comment still holds so there must be some other issue affecting the form load...

          Comment


          • #6
            Re: "can't enter break mode at this time" error with VBA References

            IMO, it would be a lot easier to late bind your Outlook objects than to try resetting references at runtime, especially as that requires the users to have access to the VBProject trusted.
            Rory
            Theory is when you know something, but it doesnít work. Practice is when something works, but you donít know why. Programmers combine theory and practice: nothing works and they donít know why

            Comment


            • #7
              Re: "can't enter break mode at this time" error with VBA References

              Hi guys. Thanks for your help. Sorry for the late reply I was away sick yesterday.

              After some trial and error (and a lot of googling), late binding seems to have sorted the problem for me

              This place is you're awesome! *Tips hat to Rory*

              Comment

              Trending

              Collapse

              There are no results that meet this criteria.

              Working...
              X