![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
All,
I'm trying to open Outlook 2007 (Vista) using VBA but unfortunately I can't seem to get it to work. I have found different variations of the following: Dim Olook As Outlook.Application Set Olook = CreateObject("Outlook.Application") Olook.Application.Visible = True but when I attempt to run the code I get a VB compile error: "user defined type not defined." Basically what I want to do is to open Outlook and go to the inbox. If anyone can help me with this I would be grateful, Thanks in advance. - CES |
Ads |
#2
|
|||
|
|||
![]() The error occurs because Outlook is unknown to you project. Add a reference to its library. To make Outlook visible, add an Explorer to its Explorers collection. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Quick-Cats - The most effective way to assign Outlook categories: http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Mon, 19 Mar 2007 19:28:06 -0400 schrieb CES: All, I'm trying to open Outlook 2007 (Vista) using VBA but unfortunately I can't seem to get it to work. I have found different variations of the following: Dim Olook As Outlook.Application Set Olook = CreateObject("Outlook.Application") Olook.Application.Visible = True but when I attempt to run the code I get a VB compile error: "user defined type not defined." Basically what I want to do is to open Outlook and go to the inbox. If anyone can help me with this I would be grateful, Thanks in advance. - CES |
#3
|
|||
|
|||
![]()
Michael Bauer [MVP - Outlook] wrote:
The error occurs because Outlook is unknown to you project. Add a reference to its library. To make Outlook visible, add an Explorer to its Explorers collection. Michael, I'm sorry but I'm not sure what you mean when you y "Add a references to it's library... could you possible point me to a simple example of how to open Outlook from Any Office 2007 application. Thanks - CES |
#4
|
|||
|
|||
![]() From any Office application, go to Tools/References and select Microsoft Outlook... from the list. If it's really necessary to have Outlook visible then modify your code a little bit: Dim Olook As Outlook.Application Set Olook = CreateObject("Outlook.Application") Olook.Explorers.Add -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Quick-Cats - The most effective way to assign Outlook categories: http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Wed, 21 Mar 2007 21:08:02 -0400 schrieb CES: Michael Bauer [MVP - Outlook] wrote: The error occurs because Outlook is unknown to you project. Add a reference to its library. To make Outlook visible, add an Explorer to its Explorers collection. Michael, I'm sorry but I'm not sure what you mean when you y "Add a references to it's library... could you possible point me to a simple example of how to open Outlook from Any Office 2007 application. Thanks - CES |
#5
|
|||
|
|||
![]()
Michael Bauer [MVP - Outlook] wrote:
From any Office application, go to Tools/References and select Microsoft Outlook... from the list. If it's really necessary to have Outlook visible then modify your code a little bit: Dim Olook As Outlook.Application Set Olook = CreateObject("Outlook.Application") Olook.Explorers.Add Michael, I've added a reference to the Microsoft Outlook 12.0 Object Library as you suggested however I am still getting errors. Public Sub test_Click() Dim oL As Outlook.Application Set oL = CreateObject("Outlook.Application") 'Either of these will throw an error 'oL.Explorers.Add ' Compile Error = "Argument not Optional" 'oL.Application.Visible = True ' Run-time error 438 = Object dosent support this property or method End Sub If by any chance you have a clue what else might be going wrong I would appreciate your help. - CES |
#6
|
|||
|
|||
![]() OK, you must tell Explorer.Add a folder to display: Dim ns as Outlook.Namespace Dim Folder as Outlook.Mapifolder Set ns=Olook.GetNamespace("MAPI") Set Folder=ns.getDefaultFolder(olFolderInbox) Olook.Explorers.Add Folder Please test it, it might be necessary later to also delete the folder by your code. You'll see that when Outlook doesn't close properly. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Quick-Cats - The most effective way to assign Outlook categories: http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Thu, 22 Mar 2007 13:07:56 -0400 schrieb CES: Michael Bauer [MVP - Outlook] wrote: From any Office application, go to Tools/References and select Microsoft Outlook... from the list. If it's really necessary to have Outlook visible then modify your code a little bit: Dim Olook As Outlook.Application Set Olook = CreateObject("Outlook.Application") Olook.Explorers.Add Michael, I've added a reference to the Microsoft Outlook 12.0 Object Library as you suggested however I am still getting errors. Public Sub test_Click() Dim oL As Outlook.Application Set oL = CreateObject("Outlook.Application") 'Either of these will throw an error 'oL.Explorers.Add ' Compile Error = "Argument not Optional" 'oL.Application.Visible = True ' Run-time error 438 = Object dosent support this property or method End Sub If by any chance you have a clue what else might be going wrong I would appreciate your help. - CES |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Chronological Dates in MS Outlook's Inbox | bkaras | Outlook - General Queries | 4 | March 14th 07 07:44 AM |
setting outlook inbox permissions thru vba | themick | Outlook and VBA | 2 | January 23rd 07 05:16 AM |
reformatting hd How to save Outlook's inbox, sent items etc | [email protected] | Outlook - General Queries | 2 | September 7th 06 09:57 PM |
Unable to add Outlook's Inbox to IE 6.0's Favorites folder... | [email protected] | Outlook - General Queries | 2 | July 19th 06 03:39 PM |
VBA code to remove flag from all messages in Inbox | [email protected] | Outlook and VBA | 11 | May 8th 06 03:30 PM |