PDA

View Full Version : [SOLVED:] Remove header and set cursor with VBA



marc651
09-22-2019, 11:29 PM
Hello,

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?

gmayor
09-23-2019, 04:06 AM
I have already explained to you how to create a macro to handle this in another post that you have marked as 'solved'.

marc651
09-23-2019, 04:55 AM
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,
Memememe

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


So it is diferent than the other post i made.

marc651
09-27-2019, 04:12 AM
Anybody any idea????

gmayor
09-27-2019, 05:54 AM
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
lbl_Exit:
Exit Sub
End Sub


Sub ReplyToMail2(olItem As Object)
'Graham Mayor - https://www.gmayor.com - 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
.Display
oRng.Start = InStr(1, oRng.Text, "Classroom") + 8
oRng.collapse 1
oRng.Text = Chr(32)
oRng.collapse 0
oRng.Select
'.Send 'restore after testing
End With
End With
End If
lbl_Exit:
Set olOutMail = Nothing
Set olItem = Nothing
Set olInsp = Nothing
Set wdDoc = Nothing
Set oRng = Nothing
Exit Sub
End Sub

marc651
09-29-2019, 05:18 AM
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?