Avatar of Jegajothy vythilingam
Jegajothy vythilingam
Flag for United States of America asked on

Outlook 2007 = exporting a single email contents to Word 2007

My OS is win 7 prof 64 bit and I use Office 2007.  I am trying to export the contents of a single email to Outlook.  Can an expert please walk me thru how to do this? Thank u.
OutlookMicrosoft Word

Avatar of undefined
Last Comment
Jegajothy vythilingam

8/22/2022 - Mon
Chris Bottomley

Can you clarify … you are trying to exports the contents of a single email (in outlook presumably) to Outlook?

Chris
Chris Bottomley

Sorry the title gives the game away … what from the email do you want to export and how should it appear in word?

Chris
Jegajothy vythilingam

ASKER
in response to Chris I want to export from Outlook 2007.  Whenever one clicks on an email and reads it.  But I want to save the contents of this Outlook 2007 email that I just read to a Word 2007 document, just all the contents, either from the Sender's information to the end of that message, or maybe just the contents only.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Chris Bottomley

The scope of what is written to word we can play with … the main concern I would have the now is triggering the macro … calling it from the run menu option is the easiest i.e. a named macro that does what you ask.

Would that work for you?

Chris
Jegajothy vythilingam

ASKER
in response to Chris,
I think a macro will work very well.  Please give me the steps to stick it wherever I am supposed to glue it.  Thank u very much for your response.
Chris Bottomley

Place the following into an outlook code module:

Sub Q_28302258_1()
Dim wrdApp As Object
Dim doc As Object
Dim mai As MailItem
Dim GetCurrentItem As Object

    Select Case TypeName(Application.ActiveWindow)
        Case "Explorer"
            Set GetCurrentItem = Application.ActiveExplorer.Selection.Item(1)
        Case "Inspector"
            Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
    End Select
    
    If TypeName(GetCurrentItem) = "MailItem" Then
        Set mai = GetCurrentItem
        Set wrdApp = CreateObject("word.application")
        Set doc = wrdApp.documents.Add
        wrdApp.Selection.typetext mai.Body
        wrdApp.Visible = True
    Else
        Exit Sub
    End If
    
End Sub

Open in new window


Chris
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Jegajothy vythilingam

ASKER
In response to Chris, thank u for your code, I have renamed the sub to : OuttoWord, but when I ran it, I got the error as in the attached file.  Maybe I have not done any prerequisites tweaking.  Thank u.
outlook-2007-macro-error.docx
Chris Bottomley

Typo

Sub Q_28302258_1()
Dim wrdApp As Object
Dim doc As Object
Dim mai As MailItem
Dim GetCurrentItem As Object

    Select Case TypeName(Application.ActiveWindow)
        Case "Explorer"
            Set GetCurrentItem = Application.ActiveExplorer.Selection.Item(1)
        Case "Inspector"
            Set GetCurrentItem = Application.ActiveInspector.CurrentItem
    End Select
    
    If TypeName(GetCurrentItem) = "MailItem" Then
        Set mai = GetCurrentItem
        Set wrdApp = CreateObject("word.application")
        Set doc = wrdApp.documents.Add
        wrdApp.Selection.typetext mai.Body
        wrdApp.Visible = True
    Else
        Exit Sub
    End If
    
End Sub

Open in new window


Tested the explorer scenario but skipped over the inspector session - I guess when you got the error you had an email open - assuming so this should resolve that issue.

Chris
Jegajothy vythilingam

ASKER
In response to Chris, I am afraid that nothing happened when I ran the code with an email open.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Chris Bottomley

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jegajothy vythilingam

ASKER
Hi Chris,
I salute u for your technical knowledge especially in the programming field.  The code worked, it opened word and created a document.  Graphics in the email was rendered a a hyperlink to the web site.
Thank u and well done.
with best wishes and happy holidays.
Jegajothy vythilingam

ASKER
a walking programming genius.  Thank u for the code.