+ Reply to Thread
Results 1 to 37 of 37

VBA crash late binding Outlook

  1. #1
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    VBA crash late binding Outlook

    New in this forum. I have a problem with some VBA code that always worked before but now suddenly crashes Excel. The code was not changed so, something else seems to be causing this.

    This is the line that crashes Excel immediately now:
    Please Login or Register  to view this content.
    Anyone who has an idea what could be causing this?

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: VBA crash late binding Outlook

    That line should not crash Excel. What specifically do you mean by "crash"? Does the process stop? Does it stay up but become unresponsive? Does it give you an error message?

    I am assuming you have
    Please Login or Register  to view this content.
    but even if you don't, it shouldn't crash.

    This suggests there is a problem with either your Excel or Outlook installation. Does Outlook seem to be working OK?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    Yes, I have that Dim statement.
    The moment the line executes, Excel closes fully. No messages, just gone.
    My Excel works fine (other than this), no issues. My Outlook is also running fine: no problems there.

  4. #4
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,024

    Re: VBA crash late binding Outlook

    Does creating other objects cause it to crash?
    e.g.
    Please Login or Register  to view this content.
    Have you tried the code in:
    1. another file?
    2. using early binding (reference to Outlook)?

  5. #5
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,229

    Re: VBA crash late binding Outlook

    I'm afraid we're dealing with a new Outlook. If so, you can forget about using macros to automate the process. Simply put, the new Outlook no longer supports VBA code.

    Artik

  6. #6
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,024

    Re: VBA crash late binding Outlook

    Perhaps. That why I wanted to know if a reference to Outlook existed.

    Still, it shouldn't crash Excel should it? You'd expect a "Can't create object" error.


    PS you can voice your disgust at that decision here
    https://feedbackportal.microsoft.com...c-000d3ae46fcb

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: VBA crash late binding Outlook

    Quote Originally Posted by Artik View Post
    the new Outlook no longer supports VBA code.
    What "new Outlook" are you taking about? Please update your profile to show your version of Excel/Office.

    I am using Outlook with Microsoft 365, latest commercial release, and it supports VBA just fine.

  8. #8
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    Quote Originally Posted by ByteMarks View Post
    Does creating other objects cause it to crash?
    e.g.
    Please Login or Register  to view this content.
    Have you tried the code in:
    1. another file?
    2. using early binding (reference to Outlook)?
    I tried in another file - same issue
    Early binding might work but I think I need late binding for my code (I can revert to this in case we can't solve my problem)

    I tried CreateObject("Word.Application") that works fine, same for Excel

  9. #9
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    Quote Originally Posted by Artik View Post
    I'm afraid we're dealing with a new Outlook. If so, you can forget about using macros to automate the process. Simply put, the new Outlook no longer supports VBA code.

    Artik
    I'm using the regular Outlook (desktop version) that came and comes with MSO365 (latest version)

  10. #10
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    More info: if I close Outlook and then run the code in Excel, the crash is still happening

  11. #11
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,386

    Re: VBA crash late binding Outlook

    Also when you run the code in a new workbook?

    What if you run it like this?
    I also have one file where Excel (randomly)crashes after sending the mails to 15 people. Never found the problem, only happening in that file...

    Please Login or Register  to view this content.
    Last edited by JEC.; 04-23-2024 at 02:55 PM.

  12. #12
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    Crashes on the CreateObject line.

    First thing I did when my code suddenly crashed was to create a new file and copy the line in there: that still crashed

  13. #13
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,386

    Re: VBA crash late binding Outlook

    Do you have add ins installed?

  14. #14
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    Good one, thanks. I had thought about that before but forgot to check earlier.
    Started Excel in safe mode, ran the code and still crashed

  15. #15
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,386

    Re: VBA crash late binding Outlook

    And add ins in outlook?

    -Are Excel and Outlook at the same version?
    -You could try and reinstall outlook
    Last edited by JEC.; 04-23-2024 at 03:28 PM.

  16. #16
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,496

    Re: VBA crash late binding Outlook

    I'm using an Office 365 subscription and have coded macros in Excel 365 which integrate with Outlook 365 using Late Binding.

    I do see the option to use the "new" Outlook interface. Is that what you mean?
    Last edited by TMS; 04-23-2024 at 03:39 PM.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  17. #17
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    Quote Originally Posted by JEC. View Post
    And add ins in outlook?

    -Are Excel and Outlook at the same version?
    -You could try and reinstall outlook
    Yes, same version (MSO365 for all). No add-ins in Outlook.
    I don't want to reinstall Outlook, all works fine in Office

  18. #18
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,229

    Re: VBA crash late binding Outlook

    Quote Originally Posted by TMS View Post
    I do see the option to use the "new" Outlook interface. Is that what you mean?
    Yes, that's exactly the switch I'm thinking of. Switching to a new interface causes, problems with the operation of automation, about which below.
    Quote Originally Posted by 6StringJazzer View Post
    What "new Outlook" are you taking about?
    Please refer to this article, possibly additional googling.
    Quote Originally Posted by ByteMarks View Post
    Still, it shouldn't crash Excel should it? You'd expect a "Can't create object" error.
    That's the way it should be, but things are mixed with Microsoft.

    I ran a short test a moment ago on version 365. In Outlook, I switched the view to "new Outlook." I closed the application, checked in the Task Manager to see if Outlook stayed among the background tasks. It was not there. In Excel, I ran the following code:
    Please Login or Register  to view this content.
    The execution of the code stopped for about 20 sec on the line CreateObject("Outlook.Application") and then reported the exception:"-2146959355 (80080005) Server execution failed". The variable oOtlk = Nothing.
    I ran the code again. The execution again stopped for a moment at the CreateObject line, and then returned an Outlook message: "We detected a problem when starting a new Outlook. Try again later." Err.Number = 0, Err.Description = "", the oOtlk variable contained a reference to the Outlook application. After completing the macro, I opened Outlook and.... by itself returned to the old view. Subsequent running of the code was already running smoothly, of course.
    That's where I ended the test.

    Artik

  19. #19
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,024

    Re: VBA crash late binding Outlook

    Thanks Artik.

    What "new Outlook" are you taking about?
    Outlook VBA is a COM addin. New Outlook doesn't support COM addins.
    Attached Images Attached Images

  20. #20
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    Not sure how I can check if I have the new Outlook (but I'm almost certain that I'm NOT using the new one)

  21. #21
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,024

    Re: VBA crash late binding Outlook

    File-->Options-->Addins

  22. #22
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    Did that... what do you want me to see there (other than the addins)?

  23. #23
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,220

    Re: VBA crash late binding Outlook

    I think the point is that if you still have the option for COM add-ins, then you haven't upgrdaed to the NEW Outlook.

    I know that I rejected an update to the new interface quite some time ago (I'm on the BETA channel) and still have COM add-ins.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  24. #24
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    Ah, OK. So yes, I don't have the new Outlook then.

    But that means that my crash is not caused by that and therefore my problem remains.
    I'll try to see if I can check early binding (but as said, I'm not sure if that will cause other problems down the line)

  25. #25
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,220

    Re: VBA crash late binding Outlook

    It would seem so - back to the VBA experts!

  26. #26
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,229

    Re: VBA crash late binding Outlook

    Classic Outlook has a ribbon very similar to the ribbon in Excel (desktop version). Unless the administrator has disabled it, there should be a "Try the new Outlook" switch in the upper right corner (pic.1).Attachment 867039 The new Outlook by its appearance looks more like a web application (pic.2)Attachment 867040

    But I think I'm late.

    Artik
    Attached Images Attached Images
    Last edited by Artik; 04-25-2024 at 09:56 AM.

  27. #27
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,220

    Re: VBA crash late binding Outlook

    You might need to check that the add-in for VBA is active - it's inactive on mine (but I don't use it). It says 'load on demand', so I think it should be active for you if it's being called correctly.
    Last edited by AliGW; 04-24-2024 at 05:23 AM.

  28. #28
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,024

    Re: VBA crash late binding Outlook

    Quote Originally Posted by TML59 View Post
    I tried in another file - same issue
    I tried CreateObject("Word.Application") that works fine, same for Excel
    Problem would seem to be Outlook.
    There can only be one instance of Outlook so CreateObject actually performs GetObject if Outlook is open.
    You could try closing Outlook and running this and see if the same thing happens.

    Please Login or Register  to view this content.

  29. #29
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    Quote Originally Posted by AliGW View Post
    You might need to check that the add-in for VBA is active - it's inactive on mine (but I don't use it). It says 'load on demand', so I think it should be active for you if it's being called correctly.
    Mine is too, I never touched it and I'm guessing it's irrelevant as this add-in is for Outlook VBA. What I'm doing is calling Outlook from Excel VBA

  30. #30
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    Quote Originally Posted by Artik View Post
    Classic Outlook has a ribbon very similar to the ribbon in Excel (desktop version). Unless the administrator has disabled it, there should be a "Try the new Outlook" switch in the upper right corner (pic.1).Attachment 867039 The new Outlook by its appearance looks more like a web application (pic.2)Attachment 867040

    But I think I'm late.

    Artik
    I don't see you attachments. I searched my desktop Outlook but see no references to a new version

  31. #31
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    Quote Originally Posted by ByteMarks View Post
    Problem would seem to be Outlook.
    There can only be one instance of Outlook so CreateObject actually performs GetObject if Outlook is open.
    You could try closing Outlook and running this and see if the same thing happens.

    Please Login or Register  to view this content.
    Thanks, already reported earlier that with Outlook closed, I still get the crash. I did however do what you suggested: created a new Excel file, added the code, closed Outlook. Still a full Excel crash (without any message or delay) on the "CreateObject" line

  32. #32
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    To build on the feedback from ByteMarks: if I change the call to "GetObject(, "Outlook.Application") I get no errror (of course I need to have Outlook open).

    Again: CreateObject had always worked for me. I did not do anything to the file or code but it suddenly just stopped and started to crash some weeks back.

    I'll explore the GetObject option a bit more and will report back here if I got things to work (but the original weird problem remains, the GetObject is a workaround)

  33. #33
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    Reading an earlier post from ByteMarks, I noticed he mentioned calling Outlook like this:
    Please Login or Register  to view this content.
    So I tried that and guess what: it works!

    So what does this mean? Note that this is not needed when I call Excel or Word... only when I call Outlook. And my installed version is and has always been MSO365, never something different with e.g. only Outlook
    Last edited by TML59; 04-24-2024 at 10:27 AM.

  34. #34
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,024

    Re: VBA crash late binding Outlook

    Maybe this as a workaround.
    Try the GetObject. If it fails open Outlook and try it again.


    Please Login or Register  to view this content.

  35. #35
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    Thanks for all the tips and suggestions. My problem is (sort of) solved and I can live with the workarounds / alternative approaches.

  36. #36
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,024

    Re: VBA crash late binding Outlook

    Re post#33 I never really got to the bottom of it. It happened after I was upgraded from Office 2007 to 365 which generated multiple registry entries.
    I got round it by running Outlook with administrator privileges, although why that worked remains a mystery.

    Don't have the same machine now and haven't experienced it again.

  37. #37
    Registered User
    Join Date
    04-22-2024
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    18

    Re: VBA crash late binding Outlook

    I was curious, so I just tested that: doesn't work here, still crashes.

    The ".16" or the "GetObject (with Shell if needed)" iso CreateObject work for me.

+ 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. [SOLVED] Late Binding for Outlook
    By dflak in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-07-2019, 01:41 PM
  2. Save birthday as Outlook calendar with recurrence every year with late binding
    By Goodstart14 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2017, 12:31 PM
  3. [SOLVED] Learning differences between Early Binding & Late Binding
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 06-28-2013, 01:16 AM
  4. [SOLVED] Seeking knowledge on Early Binding, Late Binding
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-17-2013, 10:45 PM
  5. Late Binding to Outlook Web Apps 2003 from Excel 2000
    By Dave Benson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2005, 07:00 PM
  6. Late binding issues with Excel and Outlook
    By Dave Benson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-25-2005, 11:10 PM
  7. [SOLVED] repost: need help trying to automate Outlook from XL, with late binding
    By KR in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-06-2005, 12:06 PM

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