Consulting

Results 1 to 4 of 4

Thread: Select some text from specified Outlook email to the Single Cell of the Excel Sheet

  1. #1

    Select some text from specified Outlook email to the Single Cell of the Excel Sheet

    Hi, there
    Issue 1, is it possible to copy some text from selected Outlook email to "insert comment" of single Cell in Excel worksheet?

    Issue 2, also want to know the Macro for those text from the selected Outlook email into single cell in Excel worksheet.

    Actually, I have daily email which state style# & comment. Then, I need to insert the comment to the related style# in table of the Excel file.

    Example
    Outlook to Excel.jpg

  2. #2
    The short answer is yes, but the method will depend on the format of the messages - see http://www.gmayor.com/extract_data_from_email.htm and also the link at the end of that page.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    Thanks for your reply! After reviewing your past post, found that you wrote VBA with the subject : VBA get selected text from Outlook email body and use in Excel before.

    As per your post, the email body text can be selected. But, there was no code for transfer the selected text to Single Cell of Excel worksheet.

    In my case, could you please help to advise how to transfer the selected text from Outlook email body to Excel worksheet with your previous advised code?

    Sub test()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim olInsp As Object
    Dim wdDoc As Object
    Dim strText As String

    On Error Resume Next
    'Get Outlook if it's running
    Set OutApp = GetObject(, "Outlook.Application")

    'Outlook wasn't running, so cancel
    If Err <> 0 Then
    MsgBox "Outlook is not running so nothing can be selected!"
    GoTo lbl_Exit
    End If
    On Error GoTo 0

    Set OutMail = OutApp.ActiveExplorer.Selection.Item(1)
    With OutMail
    Set olInsp = .GetInspector
    Set wdDoc = olInsp.WordEditor
    strText = wdDoc.Application.Selection.Range.Text
    End With
    MsgBox strText
    lbl_Exit:
    Set OutMail = Nothing
    Set OutApp = Nothing
    Set olInsp = Nothing
    Set wdDoc = Nothing
    Exit Sub
    End Sub

  4. #4
    Assuming the message box gives the result you require, and you are running the code in Excel, then you can simply write strText to the cell in question e.g.
    ActiveSheet.Range("A1") = strText
    in place of (or after) the MsgBox line.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •