Solved

VBA -Launch Word from Outlook - beginners question

Posted on 2004-04-26
3
562 Views
Last Modified: 2012-06-27
Hi,

I am trying to teach myself how to program in Outlook from a book.  I am now playing with VBA.  The book is written for Outlook 2002, but I am using 2003.  Here is the simple code they have me write:

Public Sub LaunchWordMail()
On Error Resume Next
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Set wdApp = CreateObject("Word.Application")
Set wdDoc = _
    wdApp.Documents.Add(DocumentType:=wdNewEmailMessage)
wdApp.Visible = True
wdApp.ActiveWindow.EnvelopeVisible = True
End Sub

This is supposed to launch a new email message, using Word as the editor.  It works on my 2002 machine but when I try it on my 2003 machine I get the following error:

Can't find project or library.

It then highlights "wdNewEmailMessge".  I have verified that the Microsoft Word 11.0 Object Library is selected in my references, and when I look through the help files it looks like I should be able to use wdNewEmailMessage.

Any thoguhts?  (and remember, I have no idea what i'm doing : )

Thanks,
tim
0
Comment
Question by:timnorvel
[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
3 Comments
 
LVL 2

Accepted Solution

by:
Soluch earned 250 total points
ID: 10967338
Hi Tim,

Try adding "Word." to "wdNewEmailMessage", i.e:

Set wdDoc = _
    wdApp.Documents.Add(DocumentType:=Word.wdNewEmailMessage)

I've had similar problems with Microsoft Access.  It may be that you have other references missing, not necessarily the Microsoft Word 11.0 object.  Check your references again, but in any event hopefully the above line of code will fix the problem.

Soluch.

0
 

Author Comment

by:timnorvel
ID: 10981233
Yes, that fixed it!!! Thanks so much.  So, the reason it didn't work is because I am missing a reference to something?  Is there a reference I should look for?  Not that I really need it now that it works this way... just seeking to understand.
0
 
LVL 2

Expert Comment

by:Soluch
ID: 10981534
The most likely reason is that you are missing a reference.  You mention that it works on your 2002 machine but not your 2003 one, so I think the 2002 machine has some files that are referenced by the macro that are missing on the 2003 machine.

Best way to check is to go to the Visual Basic Editor screen in Outloook (Tools->Macro->Visual Basic Editor or press Alt-F11), then from there view the references (Tools->References).  Look at all the ticked ones and see if any include the word “MISSING:”, if so then those are the ones that you will need to either dereference or copy from your old machine.  If you copy them over you will need to register them as well, using Regsvr32.exe from the command prompt.  If you are unsure how to do this a good place to start is: http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q249/8/73.asp&NoWebContent=1 

You could also type in "Regsv32" into google, or "Registering DLL", etc.  Of course there could be a totally different reason why it's not working... :)

Soluch.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

624 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