Several VBA tutorials within Power Spreadsheets explain how to carry out certain activities within Excel. Examples of such activities are or, or.However, in certain circumstances, you might have to (or want to) work with other applications from Excel.
This makes sense. After all, a particular process may involve applications other than Excel.Visual Basic for Applications allows you to automate other Office Applications directly from Excel.In this particular VBA tutorial, I provide a thorough step-by-step introduction to how you can work with Outlook from Excel using VBA. This is a very common (although not the only) type of integration.
Re: Auto generate ID number on Textbox userform Rather than fiddling with TabStops, one could either use a Label, or set the text box's.Locked or.Enabled properties to True. One could also use code like this to generate and preserve the ID.
In fact, it's likely that you've integrated both applications in the past. As explained by Excel MVP Mike Alexander in Excel Macros for Dummies:If you've sent or received an Excel workbook through Outlook, you've integrated the 2 programs; albeit manually.More precisely, however, this VBA tutorial focuses on how you can send an email with Outlook while working from Excel. On the way to achieving this objective you'll learn about other topics, such as the following:. The Outlook object model, and some of the most relevant constructs you must understand for purposes of sending an email using VBA. What is Automation, and how you can use it to control Outlook from Excel.I provide practical examples of VBA code that you can easily adjust and start using right now.This Send Email From Excel Using VBA Tutorial is accompanied by Excel workbooks containing the data and macros I use in the examples below. You can get immediate free access to these example workbooks by subscribing to the Power Spreadsheets Newsletter.The following table of contents lists the main topics I cover in this Excel tutorial. You can use it to quickly navigate to the section that interests you the most.Since the main topic of this blog post is how to manipulate Outlook from Excel, let's start by taking a look at The Microsoft Outlook Object Model: A Quick IntroductionMy focus in Power Spreadsheets is Microsoft Excel.
Therefore, I've previously created a comprehensive tutorial about Excel's object model. You can find this. I've also written other blog posts that explain different object models, such as that of.However, here's the deal:Each application (Excel and Outlook in this particular case) has its own object model.
When working with Visual Basic for Applications, you're (basically) manipulating the objects from the relevant application.Therefore, you need to have a good understanding of the object model of the application(s) you're working with. For this reason, I provide a quick introduction to the Outlook object model in this section.In any case, several of the more general explanations I provide in the blog post about Excel's object model to which I link to above apply (with some adjustments) to the Outlook object model.Let's start by reviewing: What Is The Outlook Object ModelYou can think of a VBA object model as a hierarchy that contains all you can work with.Within such a hierarchy, there's an object at the top. That object may contain other objects.
Those objects may, in turn, contain other objects.You probably see the pattern thereIn more general terms, each object (anywhere in the hierarchy) can contain other objects. If you continue going down the hierarchy, you eventually find an object that doesn't hold other objects.Even though the components of the Excel and Outlook object models differ, the basic idea behind them is pretty much the same.The object at the top of the Outlook hierarchy is Outlook itself or, more precisely,.
In other words, the Application object represents the Outlook application.This is similar to what happens with the Excel object model. In Excel, the object at the top of the hierarchy is also the Application object. In this case, the Application object represents the Excel application.The Outlook Application object has several useful purposes. For this VBA tutorial, the following 2 are particularly important:. Purpose #1: Since the Outlook Application object is at the top of the hierarchy, it's the root from which you access the other objects within the Outlook object model. Purpose #2: It has the CreateItem method (which I explain in the next section).
CreateItem allows you to create an Outlook item (such as an email) without having to go through the whole object model hierarchy.In order to better understand why the above makes the Outlook Application object important, let's take a look at the Application.CreateItem MethodAs I mention above, you can use to create an Outlook item.The basic syntax of CreateItem is as follows:expression. CreateItem(ItemType)Within this syntax, “expression” represents an Application object.The only parameter of the CreateItem method is ItemType. This parameter is required. You use it to specify what type of item you want to create.