+ Reply to Thread
Results 1 to 9 of 9

Office 365 GetObject function

  1. #1
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    365 32bit Win
    Posts
    1,935

    Office 365 GetObject function

    Hi, I have some code (in Excel) which automates Outlook by displaying an email populated with text for the user to send.

    Initially all users were using Office 2007 and I am using late binding
    Please Login or Register  to view this content.
    which worked fine.

    Since then, some users have upgraded to Office 365 and this code no longer works. It seems to be because outlook is now named in the registry as Outlook.Application.16 with .16 added.

    I now need the code to work on both versions and have so far I thought of either:
    1. a way for GetObject to work with either of these - perhaps a wildcard or something?
    2. a way to determine whether Office 365 is installed and use the correct name accordingly.
    3. a way to pull the application name from the registry in order to use the correct one with GetObject


    Does anyone have any way to overcome this?


  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Office 365 GetObject function

    Sounds like Outlook was not open. You need On Error to handle that. See the link for details.

    Avoiding version issues is why late binding is used.

    Whether you use early binding or late binding, this routine may be helpful. https://www.rondebruin.nl/win/s1/outlook/openclose.htm
    Last edited by Kenneth Hobson; 09-06-2019 at 09:24 AM.

  3. #3
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    365 32bit Win
    Posts
    1,935

    Re: Office 365 GetObject function

    Thanks for your reply. The odd thing is that Outlook is open. If I change GetObject(, "Outlook.Application") to GetObject(, "Outlook.Application.16") it works.
    However I've since found someone with a similar setup where this problem doesn't occur, i.e. registry shows the .16 name and GetObject(, "Outlook.Application") is successful, so unfortunately it seems like it may be a localised issue.

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Office 365 GetObject function

    Have you tried using

    Please Login or Register  to view this content.
    Even better would be posting your current code so we can check.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Office 365 GetObject function

    First, reboot the other computer, open Outlook, and then try the code. Obviously, CreateObject() and GetObject() will error if Outlook is not open.

    If still an issue, check on their computer, VBE > Tools > References > Microsoft Outlook 16.0 Object Library. If it does not exist, that is the problem.

    A modify/repair or reinstall of Microsoft Office should repair it. Click Windows button, type App, select Apps and Features, select Microsoft Office 365 and then Modify.

    Or, you can try RegSvr32 for the TLb or DLL. The References dialog does not show the full path referenced for that object in mine. If path can be found, trying RegSvr32 might work.
    Last edited by Kenneth Hobson; 09-06-2019 at 12:33 PM.

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Office 365 GetObject function

    @ Kenneth

    CreateObject works with Outlook closed. Try this with Outlook closed.
    Please Login or Register  to view this content.

  7. #7
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Office 365 GetObject function

    I test most everything that I post. Outlook has issues on this computer. I use a profile other than the standard outlook profile for it. When testing from the standard profile on another computer, open does not matter.

    If #6 or #4 ran with outlook closed in the non-standard Outlook profile:
    OutlookClosedError.png
    If ran with outlook open, no error.

    I most always have Outlook open so it is seldom an issue for me on any computer.
    Last edited by Kenneth Hobson; 09-06-2019 at 02:30 PM.

  8. #8
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    365 32bit Win
    Posts
    1,935

    Re: Office 365 GetObject function

    Hi, Thanks for the replies so far. I still have this issue.

    There's a function which I used to check if Outlook is running which currently returns False even when Outlook 365 is running.
    Please Login or Register  to view this content.
    If this returns true, then the main part of the code creates an email for the user to edit.
    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    365 32bit Win
    Posts
    1,935

    Re: Office 365 GetObject function

    Hi All,

    I have discovered that the cause was that Outlook needed to be run as Administrator.

+ 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. VBA GetObject Runtime
    By dontbugme1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-20-2016, 09:03 AM
  2. Getobject()
    By excelnsn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-03-2012, 07:12 AM
  3. GetObject how does it works ???
    By ina in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-12-2006, 12:50 PM
  4. [SOLVED] GetObject with Password
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-30-2006, 06:55 AM
  5. GetObject
    By Maxi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-14-2006, 06:25 AM
  6. GetObject equivalent for IE
    By spaceman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-15-2005, 03:35 AM
  7. [SOLVED] GetObject Function On Text Files
    By William Horton in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2005, 05:05 PM

Tags for this Thread

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