?
Solved

VBA Compatibility between Word/Outlook - 2003 & 2007

Posted on 2009-07-01
2
Medium Priority
?
180 Views
Last Modified: 2012-05-07
I have a Word template that generates an email in Outlook.

My problem is that some users are on Office 2007, and some are on 2003, so when the macro runs, it brings up errors because the required reference library is missing, and because I don't have both versions of Outlook installed on my PC, I can't select both.

Is there a way to get this to work, regardless of which version of Word or Outlook the user is on?
0
Comment
Question by:lp3535
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 total points
ID: 24760038
lp3535 said:
>>Is there a way to get this to work, regardless of which version of Word or Outlook the user is on?

Yes: use late binding.  In late binding, you do not set a reference to the external library, and you declare
objects as type Object rather than the proper class from the external library.  You also have to avoid using
named constants from the external library.

The snippet below shows an example of late binding:

Dim olApp As Object
Dim olMsg As Object

Set olApp = CreateObject("Outlook.Application")
Set olMsg = olApp.CreateItem(0)
With olMsg
    .To = "X@z.com"
    .CC = "y@z.com"
    .BCC = "z@z.com"
    .Subject = "subject"
    .Body = "body"
    .Attachments.Add "c:\folder\subfolder\foo.xls"
    .Send
End With

Set olMsg = Nothing
Set olApp = Nothing
0
 

Author Comment

by:lp3535
ID: 24760902
Brilliant.  Thanks for that, it works perfectly.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question