Results 1 to 6 of 6

Thread: Remove header and set cursor with VBA

  1. #1

    Remove header and set cursor with VBA


    I would like a macro that when answering(by pushing a button in the ribbon)
    removes the header. (the 'From:', 'Sent:', 'To:' & 'Subject:')
    After doing this i would like the cursor to set after a particular word. In this case 'Classroom'.
    And is it posible to do all this without opening a new window when answering?

  2. #2
    I have already explained to you how to create a macro to handle this in another post that you have marked as 'solved'.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes

  3. #3
    The post you are refering to is about getting data from the original mail, and put that in the answer.
    And allthow it works very good, it doesn't remove the header when answering.
    The code i am lokking for now is for a difirent concept.

    This mail comes in with the answer allready above it.
    When answering it, i want to remove the header that apears, and use the code you provided to set the cursor after a spcific word.
    This is globaly how it looks like when i get the mail.

    Dear Fred Test,
    In respons to your application Classroom is reserved for you for the 5th until 8th hour on 1-1-2019.

    Beste Regards,

    Via the website we received the following application.
    Name: Fred Test
    Email: …………
    Date: 1-1-2019
    Hours: 5th until 8th
    Persons: 15

    So it is diferent than the other post i made.

  4. #4
    Anybody any idea????

  5. #5
    The macro I posted in response to your other question creates a reply to the current message. It is difficult to understand the concept of what you are trying to do here but based on your comments I think what you are looking for is as follows. It is necessary to display the message.

    Sub TestCode()
    Dim olMsg As MailItem
        On Error Resume Next
        Set olMsg = ActiveExplorer.Selection.Item(1)
        ReplyToMail2 olMsg
        Exit Sub
    End Sub
    Sub ReplyToMail2(olItem As Object)
    'Graham Mayor - - Last updated - 27 Sep 2019
    Dim olOutMail As MailItem
    Dim olInsp As Outlook.Inspector
    Dim wdDoc As Object
    Dim oRng As Object
        If TypeName(olItem) = "MailItem" Then
            With olItem
                Set olOutMail = olItem.Reply
                With olOutMail
                    .Body = olItem.Body
                    Set olInsp = .GetInspector
                    Set wdDoc = olInsp.WordEditor
                    Set oRng = wdDoc.Range
                    oRng.Start = InStr(1, oRng.Text, "Classroom") + 8
                    oRng.collapse 1
                    oRng.Text = Chr(32)
                    oRng.collapse 0
                    '.Send 'restore after testing
                End With
            End With
        End If
        Set olOutMail = Nothing
        Set olItem = Nothing
        Set olInsp = Nothing
        Set wdDoc = Nothing
        Set oRng = Nothing
        Exit Sub
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes

  6. #6
    Graham Mayor.
    Exactly what I needed. This is going to sabe me a ton of time and work.
    Thanks very much.

    But so to be clear. This kind of responses with VBA is not possible in an InLine reply?

Posting Permissions

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