?
Solved

VBA -Launch Word from Outlook - beginners question

Posted on 2004-04-26
3
Medium Priority
?
564 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 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

719 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