?
Solved

Access the WordEditor object in Outlook VBA

Posted on 2010-01-06
6
Medium Priority
?
932 Views
Last Modified: 2012-05-08
I need to install a Word Add-in in the Word application in Outlook (using Word as editor in Outlook 2003). I have the code below, but it didn't work - I don't have any inspectors on startup.

Please help me make my code run.
Private Sub Application_Startup()
    Set myInspector = Item.GetInspector
    Set worddoc = myInspector.WordEditor
    worddoc.AddIns.Add FileName:="addin.dot", Install:=True
End Sub

Open in new window

0
Comment
Question by:thor_ostergaard
  • 3
  • 2
6 Comments
 
LVL 28

Expert Comment

by:peakpeak
ID: 26188245
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 26188266
Hello thor_ostergaard,

Private Sub Application_Startup()
    Set myInspector = Item.GetInspector

The sub is run at startup and as such there is no item instantiated therefore the assignment fails.

Basically the inspector will associate to a mailitem in this instance so until you which mailitem to work upon the script is 'stumped'/

Regards,

chris_bottomley
0
 

Author Comment

by:thor_ostergaard
ID: 26188289
I know - but I can see Word is starting with Outlook (before any mail items are created).
Is there a way I can access that Word instance without creating a mail item?
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 26188303
Not that I know of ... but it ought not be necessary to create an item you can latch onto an existing item.

More importantly though what are you trying to achieve and perhaps that spec ific can be addressed?

Chris
0
 

Author Comment

by:thor_ostergaard
ID: 26188336
In my Word startup folder I have an add-in with some code in it (in this case the code installs another add-in, but that's not important).
If I start Outlook before Word the code in my add-in don't get executed - and starting Word after Outlook didn't execute the code either. Therefore I will have a copy of the code from the add-in in Outlook to make sure the code gets executed.
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 2000 total points
ID: 26188456
Honest answer I don't know a streamlined way to do this, as a kludge have you tried opening word as the first activitiy in the outlook startup?

Dim wd As Object
    Set wd = CreateObject("word.application")
    wd.Visible = True

Alternatively assuming the general syntax of your initial post is corrrect and the inbox does have at least 1 item  then perhaps:

Chris
Private Sub Application_Startup() 
    Set myInspector = application.session.getdefaultfolder(olfolderinbox).items(1).GetInspector 
    Set worddoc = myInspector.WordEditor 
    worddoc.AddIns.Add FileName:="addin.dot", Install:=True
End Sub

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Today as you open your Outlook, you witness an error message: “Outlook is using an old copy of your Outlook Data File…”. Probably, Outlook is accessing an old OST file.
I came across an unsolved Outlook issue and here is my solution.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

809 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