A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Open Outlook's inbox with VBA



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 19th 07, 11:28 PM posted to microsoft.public.outlook.program_vba
CES
external usenet poster
 
Posts: 10
Default Open Outlook's inbox with VBA

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  
Old March 20th 07, 06:15 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Open Outlook's inbox with VBA



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  
Old March 22nd 07, 01:08 AM posted to microsoft.public.outlook.program_vba
CES
external usenet poster
 
Posts: 10
Default Open Outlook's inbox with VBA

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  
Old March 22nd 07, 06:17 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Open Outlook's inbox with VBA



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  
Old March 22nd 07, 05:07 PM posted to microsoft.public.outlook.program_vba
CES
external usenet poster
 
Posts: 10
Default Open Outlook's inbox with VBA

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  
Old March 23rd 07, 05:56 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Open Outlook's inbox with VBA




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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 11:05 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.