vb code to copy to excel or word item/items from inbox

I would like to copy the selected document in my inbox to an excel or word document.
Is that possible?
zachvaldezAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David LeeCommented:
Hi zachvaldez,
> selected document

Do you mean the selected message?  Or are you talking about an attachment?

Cheers!
0
zachvaldezAuthor Commented:
selected message
0
David LeeCommented:
Then I think I can do that.  I'll post the code within the next 24 hours.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

David LeeCommented:
zachvaldez,

Well, I'm a little late, but here's the code.  This macro will copy the body of the selected message into a new Word document.  Here's what you'll need to do to use the macro.
1.  Open Outlook
2.  Click Tools->Macros->Visual Basic Editor
3.  If not already expanded, expand Modules and click on Module1
4.  Copy the code below and paste it into the right-hand pane of the VB Editor
5.  Click the diskette icon on the toolbar to save the code
6.  Close the VB Editor
7.  Select a message and run the macro

'Macro begins here
Sub OpenSelectedMessageInWord()
    Dim objSelectedItems As Outlook.Selection, _
        objMessage As Outlook.MailItem, _
        objItem As Object, _
        objWordApp As Word.Application, _
        objWordDoc As Word.Document
    Set objSelectedItems = Application.ActiveExplorer.Selection
    If objSelectedItems.Count > 0 Then
        Set objWordApp = CreateObject("Word.Application")
        For Each objItem In objSelectedItems
            If objItem.Class = olMail Then
                Set objMessage = objItem
                Set objWordDoc = objWordApp.Documents.Add(, , 0)
                objWordDoc.Content.InsertAfter objMessage.Body
                objWordApp.Visible = True
            End If
        Next
    End If
    Set objItem = Nothing
    Set objMessage = Nothing
    Set objSelectedItems = Nothing
    Set objWordDoc = Nothing
    Set objWordApp = Nothing
End Sub
'Macro ends here
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zachvaldezAuthor Commented:
Ok that worked! I'll raise for another 100 points .
I'd like a template in word that would accept the following bookmarks from outlook to continue what we outputted above.
the word doc created should come from a template

Outlook>>    Word template
From:>>> From
Body:>>>> Body

There should be a header/footer area in the template to include a Date field.


In the footer shold be able to attached any attachments

0
David LeeCommented:
zachvaldez,

Sorry, I'm not good enough with the Word object model to manage that.  
0
zachvaldezAuthor Commented:
OK I'll take the first answer because it answered that question! you have extra points for honesty..
0
David LeeCommented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.