+ Reply to Thread
Results 1 to 3 of 3

First Macro Ran Causes Debug

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-03-2008
    Posts
    387

    First Macro Ran Causes Debug

    Hi,

    I have a button that triggers a macro to run.

    The first-time I press this button, the VBA editor pops open and stops on the first line of code (shown below).
    Set currentExplorer = Application.ActiveExplorer
    No error is displayed, and if I click continue, it runs fine. The next time I click the button, it runs fine and doesn't cause a breakpoint.

    I don't think this has to do with the macro, but I'm posting below just in case. My guess is it has something to do with Outlook security.

    Any suggestions are appreciated. Thanks in advance!

    Public Sub SD_Open()
        Dim Session As Outlook.NameSpace
        Dim currentExplorer As Explorer
        Dim Selection As Selection
        Dim currentItem As Object
        Dim currentMail As MailItem
        Dim currentID As String
        Dim currentLink As String
        Dim browser As Object
        Dim b As Integer
        Dim e As Integer
        Dim iUser As String
        
        Set currentExplorer = Application.ActiveExplorer
        Set Selection = currentExplorer.Selection
        
        For Each currentItem In Selection
            If currentItem.Class = olMail Then
                Set currentMail = currentItem
                currentID = currentMail.subject
                b = InStr(1, currentID, "[")
                e = InStrRev(currentID, ":")
                If b = 0 Or e = 0 Or e < b Then
                    currentID = InputBox("Could not find SD Number, please enter #:", "SD #")
                    If Not isnumeric(currentID) Then
                        Exit Sub
                    End If
                Else
                    b = b + 2
                    e = e - 1
                    currentID = Mid(currentID, b, e - b)
                End If
                currentLink = "http://website.com/Form.aspx?cwformtype=edit&pid=" & _
                    currentID
                Set browser = CreateObject("InternetExplorer.Application")
                browser.Visible = True
                browser.Navigate (currentLink)
            End If
        Next currentItem
    End Sub
    Last edited by yawnzzzz; 06-09-2015 at 10:09 AM. Reason: Reply worked.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: First Macro Ran Causes Debug

    try this:-

    On error resume next
    Set currentExplorer = Application.ActiveExplorer
    Set currentExplorer = Application.ActiveExplorer
    On error goto 0
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Contributor
    Join Date
    08-27-2006
    Posts
    136

    Re: First Macro Ran Causes Debug

    You will find many different suggested solutions with an internet search for "phantom breakpoint vba".
    To mark "Solved" go to Thread Tools.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need help with debug issue with macro
    By Lylestyle89 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-10-2015, 01:36 PM
  2. VBA Code Runs in Debug Mode But Returns Type Mismatch Error Outside Debug Mode
    By valerie.k.chiang in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-24-2014, 03:48 PM
  3. Macro debug error
    By dtgheath in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2012, 06:26 PM
  4. Macro Hangs. Help Debug? :)
    By farzyness in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2010, 03:34 PM
  5. Macro - debug error
    By emptycucumber in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-19-2009, 07:03 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1