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
Bookmarks