0

Using the thread Here I have created a macro that will open up a template in a new message window. My signature is still at the bottom though.

I want to empty the email content before adding the template, I'm new to VBA and not sure how to do it!

How is this done?

Current code:

Sub TemplateName()
    Set msg = Application.CreateItemFromTemplate("C:\Users\xyz\Desktop\template.oft")
    msg.Display
End Sub

I want to empty the email before running this sub.

Panomosh
  • 221
  • 1
  • 4
  • 15

2 Answers2

0

Set the signature to none for "New messages".

File | Options | Mail | Signatures

New messages: (none)

niton
  • 1,796
  • 14
  • 21
  • I want to keep the signatures on. This is just going to be a button that runs the macro which will open a compliant email template. All I need to do is empty the contents of the email before inserting the template and it's ridiculously complicated! – Panomosh Nov 20 '14 at 10:32
  • @Panomosh The template generates a new message. There is nothing before this step so there is nothing to empty before you see the mail item with the signature. – niton Nov 20 '14 at 21:41
0

Determine the length of the template text and keep only that.

Let's say the start of the signature is unique.

Dim sig_start as long
Dim template_text_end as long

sig_start = InStr(msg.Body, "unique text at the start of the signature")
template_text_end = sig_start - 1
msg.Body = Left(msg.Body, template_text_end)
debug.print template_text_end

When you have determined the position of the end of the template text you may decide not to figure it out every time.

You may need to try msg.HTMLBody.

Manipulating the body is tricky, you may lose the formatting.

niton
  • 1,796
  • 14
  • 21