<

Outlook View Control OVC |  part two | Changing folders and interacting programmatically! Access 2007

Published on
13,047 Points
6,147 Views
4 Endorsements
Last Modified:
Approved

Welcome to part two of my outlook view control tutorial/article/faq. In this tutorial I will show you how to interact with the ovc you have put on your form. if you are reading this and don’t have the ovc on a form yet go check out part one of this article http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4616-Outlook-View-Control-OVC-part-one-Putting-the-OVC-on-an-Access-2007-form.html

Ok first I will quickly go over the non programmatic way of changing the “folder”/ what you see and then I will get into the code that you can use to interact with the OVC in Access.

To change your “folder”/what you see
1.      Right click on the ovc
2.      In the right click menu that appears select “Properties”
3.      In the properties menu click on the “folder” line so that it is selected.
4.      After you have clicked in the “folder line go up to the textbox at the top of the properties window and in it type the word “calendar”
5.      After you have typed in the word “calendar” click the “apply” button located on the left side of the text box where you just typed in “calendar.”
Bam!! You should now see one of the views of your calendar.

If you want to change the view of the calendar goto the properties menu select “view” and in the textbox on the top of the properties window type in one of the following options then click the apply button.

Day/Week/Month
Day/Week/Month View With AutoPreview
All Appointments
Active Appointments
Events
Annual Events
Recurring Appointments
By Category
Outlook Data Files
Month

In the properties menu you can change any of the options. I have not explored to many of them myself but if you find one that is neat please share it with me.
      
Alllright lets get to the coding.

First the references :
There are two references that you will need to set before you can work with the ovc. They are:
Microsoft forms 2.0 object library
Microsoft office outlook view control

Variables:
Declare these two variables:
Dim MyFrame as Frame
Dim VC as ViewCtl

Now your ready to begin interacting with your code
      
Lets set the ovc to show our calendar.
In an event such as a button’s onclick event put this code.

‘--------start of code
Set MyFrame = Me.Frame0.Object
	Set VC = MyFrame!ViewCtl1

With VC
	.Folder = “Calendar”  ‘<<set the folder to calendar
.View = Day/Week/Month View With AutoPreview ‘<<set the view
End with 
‘---------end of code

Open in new window


The other views that can be used are the same as what you can used in the properties menu.
Day/Week/Month
Day/Week/Month View With AutoPreview
All Appointments
Active Appointments
Events
Annual Events
Recurring Appointments
By Category
Outlook Data Files
Month

Now the code to view the inbox.
The inbox is the default folder but if you have switched to the calendar folder you can switch back using this method.
 Use this code in an event such as a button’s onclick event or a form’s onload event.
‘----------start of code
Set MyFrame = Me.Frame0.Object
Set VC = MyFrame!ViewCtl1

With VC
	.Folder = “Inbox”  ‘<<set the folder to inbox
.View = Messages ‘<<set the view
End with


‘-------------end of code

Open in new window


Some other views for the inbox are.
Messages
Messages with AutoPreview
Last Seven Days
Unread Messages in This Folder
Sent To
Message Timeline
Outlook Data Files
Documents

OK that’s all I’m going to cover in this one. I might make another article on some of the other things in outlook you can access using the ovc.
Such as send an email and set an appointment.
Have Fun...

Take a look at the sample database to this one so that you can see a working version of this.
I hope everyone who reads this learns something and finds it helpful.

Thanks for reading!


OVC.accdb
4
Comment
Author:conagraman
2 Comments
LVL 10

Author Comment

by:conagraman
Mark

awesome! thank you again!

Cheers,
conagraman
0

Expert Comment

by:elbitcho
I have tried to implement the same in a Access 2013 client form, however it appears the Folder and View properties can no longer be set, either manually or in code. Do you by chance have a similar solution for Access 2013?

Thanking you in advance! with fingers crossed

Cheers,
Dale
0

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Join & Write a Comment

With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month