none
Object library feature not supported (anymore) :( ... RRS feed

  • Question

  • Hoping someone can help me with some handy delete code that I like to use in Outlook. 

    It's particularly good at deleting embedded objects (no other way to delete that stuff is there?).

     Set objCurrentItem = Application.ActiveInspector.CurrentItem - is no longer supported ("Object library feature not supported" error message).

    My code (found somewhere a long time ago now)...

    Sub DeleteAttachments()
     Dim objCurrentItem As Outlook.MailItem
     Dim colAttachments As Outlook.Attachments
     Dim objAttachment As Outlook.Attachment

     Set objCurrentItem = Application.ActiveInspector.CurrentItem
     Set colAttachments = objCurrentItem.Attachments
    ' Set strFolderpath = CreateObject("WScript.Shell")

     While colAttachments.Count > 0
        colAttachments.Remove 1
     Wend

     Set objAttachment = Nothing
     Set colAttachments = Nothing
     objCurrentItem.Save
     objCurrentItem.Close (olDiscard)
     Set objCurrentItem = Nothing

    End Sub

    Tuesday, February 7, 2017 11:30 PM

Answers

  • I experienced the same problem after Office 2016 was upgraded to Office365 and found a bizarre workaround;

    Not wanting to wreck what was a perfectly functioning macro that had been working for years I decided to make a copy and rename it slightly. That was all that was need to be done, the darn thing started working once again???? Go figure that one out, refused to compile until I made a copy of it?

    Hope this works for everyone else,

    <g class="gr_ gr_423 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="423" id="423">Dreadfool</g>.

    Monday, July 3, 2017 10:38 AM

All replies

  • Where are you running this code? In Outlook itself, or from another application such as Word or Excel?

    If you're running the code in Outlook, it should work as long as you have opened a mail message.

    If you're running it from another application, you need to automate Outlook and create an Outlook.Application object.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Wednesday, February 8, 2017 5:46 AM
  • Yep, in Outlook, w' mail message open.

    (Office 365 Business Premium).

    Here's a screenshot...

    https://1drv.ms/i/s!AjwgsYmRt63ph9JAeP0CIe6SiGbc5Q



    Wednesday, February 8, 2017 11:17 AM
  • Update...

    I've just tried this on another PC, and it's fine.

    So this is something that's happened to the current PC, fairly recently.  Just don't know how to fix it.

    Wednesday, February 8, 2017 11:39 AM
  • Update...

    I've just tried this on another PC, and it's fine.

    So this is something that's happened to the current PC, fairly recently.  Just don't know how to fix it.

    Try running a repair on the Office installation.

    Also, check the References in the project to see if any are missing. I've read that some people have fixed this issue by re-ordering the selected references.


    Paul ~~~~ Microsoft MVP (Visual Basic)


    Wednesday, February 8, 2017 1:34 PM
  • OK...

    chkdsk c: /f and reboot.

    Reinstall Office (I selected the full/long re-install)

    Start Outlook, set to prompt for all macros, restart Outlook, and

    same error! :(

    Wednesday, February 8, 2017 10:24 PM
  • I'm having a similar issue having just updated Office 2016 to the latest build (version 1702 build 7870.2024). In my case, I am getting "object Library feature not supported" error message on the following line, which was working perfectly before :

    Dim objOL As Outlook.Application
    Set objOL = CreateObject("Outlook.Application")   << Error

    I wrote this code, or at least most of it. Something has changed in the object model OR the references. I'm not sure, and I am short on time at the moment to investigate, but to me this seems like a bigger issue.

    EDIT : Try changing the Dim statement to just "Object", ie --

    Dim objCurrentItem As Object

    Does this work? I got my code to work by setting a number of things back to the generic "object". Also, you may now not need (or be able) to set them to "nothing" at the end. If these lines error, just comment them out, they are tidy up code which is somewhat optional (someone may take offense to this!).


    • Edited by Saulysw Thursday, March 23, 2017 10:50 PM additional details
    • Proposed as answer by tcollart Tuesday, September 26, 2017 5:23 PM
    Thursday, March 23, 2017 10:26 PM
  • 1701 build here.  Same problem continues.  Updating Office right now, don't think it'll help.  Will report back in a few minutes.
    Thursday, March 23, 2017 10:30 PM
  • V1702 build 7870.2024 - problem still exists :(
    Thursday, March 23, 2017 10:47 PM
  • Did you try changing your DIM statements to object, as above? Once changed, try compiling the VBA to see if there are other issues, or just run the code.
    • Edited by Saulysw Friday, March 24, 2017 12:43 AM
    Friday, March 24, 2017 12:42 AM
  • Yes - I just experienced this issue today.  Resolved by declaring as object as per above: 

    Previously used (worked well for many years): Dim myInbox as Outlook.Folder

    Now: Dim myInbox as Object 

    Compiles and functions fine...?

    • Proposed as answer by Dreadfool Monday, July 3, 2017 10:35 AM
    • Unproposed as answer by Dreadfool Monday, July 3, 2017 10:35 AM
    Thursday, June 29, 2017 10:01 AM
  • I experienced the same problem after Office 2016 was upgraded to Office365 and found a bizarre workaround;

    Not wanting to wreck what was a perfectly functioning macro that had been working for years I decided to make a copy and rename it slightly. That was all that was need to be done, the darn thing started working once again???? Go figure that one out, refused to compile until I made a copy of it?

    Hope this works for everyone else,

    <g class="gr_ gr_423 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="423" id="423">Dreadfool</g>.

    Monday, July 3, 2017 10:38 AM
  • I experienced the same problem after Office 2016 was upgraded to Office365 and found a bizarre workaround;

    Not wanting to wreck what was a perfectly functioning macro that had been working for years I decided to make a copy and rename it slightly. That was all that was need to be done, the darn thing started working once again???? Go figure that one out, refused to compile until I made a copy of it?

    Hope this works for everyone else,

    <g class="gr_ gr_423 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="423" id="423">Dreadfool</g>.

    Hey man, well that sounds promising.  Who'd have thought, LOL.

    Just wondering though - *what* did you rename?  The functions themselves?

    Cheers,  Duncan.

    UPDATE: Obviously, yes! - I've just renamed my two functions, added the word All, so they're now "SaveAllAttachments" and "DeleteAllAttachments" - and yep, I can report it's now working!

    Duncan.


    Monday, July 3, 2017 11:53 PM
  • Wow!  this worked for me too! Very slight rename and it's good again!

    Thank you!!!

    Tuesday, July 11, 2017 1:33 PM
  • I used the information in this thread to do the following:

    For each function in which you get the error, rename the function (or Subroutine). There is no need to change all the places where this function is called. recompile and then this error goes away. You will get errors if this function was called at other places. Ignore them and rename back the offending function to previous name, recompile and then all is again good.

    Wednesday, July 12, 2017 3:00 PM
  • This (basically) worked for me too.

    In preparation for making a new copy, however, I renamed the old one, doing find/replace, within the procedure, of myProcedureName/myProcedureNameXX.  After that step, I found I could now successfully compile the module, so I reversed the find and replace (myProcedureNameXX/myProcedureName) and (compiled again) was good thereafter.

    Thank you for the solution!
    Wednesday, July 26, 2017 6:43 AM
  • Thanks Saulysw!

    Our IT must be way behind because I just started getting this last week :-)

    Monday, August 21, 2017 12:55 PM

  • Dim objOL As Outlook.Application
    Set objOL = CreateObject("Outlook.Application")   << Error

    EDIT : Try changing the Dim statement to just "Object", ie --

    Dim objCurrentItem As Object

    Does this work? 

     Had the exact same issue with some code and this was the solution.  Thanks Saulysw!
    • Edited by Lee Sparks Thursday, October 5, 2017 9:12 PM typo
    Thursday, October 5, 2017 9:11 PM
  • Today my Office 365 updated automatically to version 16.0.8625.2121.

    Now all my vba code in Outlook 2016 with:
    Dim oOutlook As Outlook.Application
    and
    Set oOutlook = CreateObject("Outlook.Application")

    produces the Object library feature not supported error on the Set statement.

    Is the workaround, change:
    Dim oOutlook As Outlook.Application statement
    to
    Dim oOutlook As Object

    the recommended MSDN solution or is there a more serious problem here?

    I have a lot of Dim statements like this:
    e.g. Dim oDeleted As Outlook.Folder or Dim oItems As Outlook.Items

    and I don't want to have to change them all due to another possible issue.


    • Edited by avant-guvnor Saturday, November 11, 2017 5:12 PM avatar
    Monday, November 6, 2017 6:09 PM
  • I worked perfectly changing names

    Wednesday, November 8, 2017 1:39 PM
  • Holy Toledo, Batman! This actually worked.

    So, the question for Microsoft is... why do perfectly good functions throw errors for no reason, and why does something as bizarre as renaming the function fix the problem?

    Thursday, November 9, 2017 6:52 PM
  • That'd be a question for Microsoft to answer :)

    We're waiting Microsoft! :)

    Thursday, November 9, 2017 9:02 PM
  • Dude, that is the strangest thing... and it just worked for me to fix an Outlook macro that was hanging!
    Monday, May 7, 2018 2:59 PM
  • Amaze with that solution,,  just add a digit to each I have save and send it back to original name to not have issues with my rules, and all works perfectly. Still Can't believe it. But I witness and works
    Tuesday, August 20, 2019 6:05 AM
  • Indeed, bizarre. Copied the content, saved, stopped Outlook, start Outlook and add content, save Macro. Fixed..........

    Wednesday, October 23, 2019 1:33 PM