5

Sometimes when I'm inspecting some variable on my excel macro, Outlook opens up by itself. This is pretty annoying since I don't even use Outlook nor have it configured. What is happening here?

I'm using Office 2016.


Edit: I don't think this has any to do with the actual macro, but anyway, here it goes:

Sub duplicateSheets()
    Dim i As Integer
    For i = 1 To 3
        ThisWorkbook.Sheets("classes").Copy _
            After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)

        ThisWorkbook.Sheets("pivot").Copy _
            After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
    Next
End Sub

Outlook opens when I'm inspecting ThisWorkbook.Sheets("classes").

Community
  • 1
  • 1
mathiasfk
  • 1,278
  • 1
  • 19
  • 38
  • This isn't clear - what does your macro contain? Unless this is just a coincidence of some type, it would seem you have code in your macro attempting to access a property of Outlook, which opens it as a result. – Grade 'Eh' Bacon Feb 19 '16 at 14:54
  • @Grade'Eh'Bacon see my edit – mathiasfk Feb 19 '16 at 15:08
  • That's very weird... so it happens consistently when you inspect the variable? – Grade 'Eh' Bacon Feb 19 '16 at 15:10
  • Yes, very weid... I even created another file to make sure it has nothing to do with the content of the sheets, and it happened again – mathiasfk Feb 19 '16 at 15:23
  • For what it's worth, I've attempted to recreate your situation, and it doesn't do the same thing for me. This is with Office 2010. – Grade 'Eh' Bacon Feb 19 '16 at 15:26
  • Uninstall Outlook from your PC if you are not using it. You may also need to repair your current Office installation. – Iron Man Feb 19 '16 at 15:48
  • does the `Sheets("classes")` have any event code inside it (that possibly could be causing issue). I assume it doesn't because of your previous comment, but thought I would check anyway. – Scott Holtzman Feb 19 '16 at 15:50
  • @ScottHoltzman my original file had the `Workbook_Open` that would call a different Sub, but as I said, I've tried with a minimal test case, with only the Copy method (no workbook events), and the situation happened again – mathiasfk Feb 19 '16 at 15:57
  • @IronMan yes, I guess I'll have to do that, although it seems uninstalling only one tool of the Office 2016 package isn't as straight forward as one would expect – mathiasfk Feb 19 '16 at 16:04
  • Try running a repair first. That may be easier than trying to uninstall Outlook alone. – Iron Man Feb 19 '16 at 16:05
  • search for the word "outlook" in your vba project ! – iDevlop Feb 20 '16 at 09:03
  • I had Outlook startup on me unexpectedly yesterday. I had Excel and VBA editor open - I never tried to repeat the problem. – OldUgly Apr 07 '16 at 19:04
  • Something to do with Mail envelope? (Look at a variant in debug mode) – seadoggie01 Apr 14 '16 at 16:36

1 Answers1

1

I've had something similar happen to me before only with Access. My Excel VBA code never interacted with Access but it would still open up. Never got any errors from it, but I agree, it is rather annoying to have to close it every time.

After searching around I found that it was because I had the Microsoft Access 15.0 Object Library reference turned on. I guess some property or method that I would call from my Excel VBA would somehow trigger something in the Access Library and it would open up the application.

See if you have any Library references to Outlook enabled and turn them off, it might fix the issue you are having.

  • 1
    Probably you are right, I didn't had the Outlook reference explicitly, but I see that I had the `Microsoft Office 16.0 Object Library` is on. Maybe only the `Microsoft Excel 16.0 Object Library` is enough. – mathiasfk Aug 18 '16 at 14:09
  • Just tested the code, and actually the problem does not happen anymore (my Windows 10 was updated a few times since I first posted this question). But I guess this is the way to go to whom may have this problem in the future. Thanks a lot. – mathiasfk Aug 18 '16 at 14:14