Command Button to insert Email Signature

J

JK

I want to create a command button in Outlook 03 that would automatically
insert an email signature. One way was to copy the signature, record a new
macro and then click paste. These instructions I found online don't work
becuase all the macro is doing is pasting whatever is in the clipboard. If
you copy something else or restart the PC the macro fails.

So I think the best way is to hardcode it using VBA. I have the following
example that I found online and it works except it does not account for
formatting. One of the owners of the business I work for wants the ability to
easily insert a signature. However, he would also like to be able to select
the font for the sig which may or may not be the same as the message body.

I need to be able to program the selected font, size, and bold/italic
directly into the code below. I've never done this - does anyone know where I
could find an example of this online or be able to tell me how to do it?

Oh, and you'll notice I commented out the last line in the following code
"MyRange.InsertAfter (MyText)" if I don't comment it out the text is printed
twice?

Thanks,
Jason

Sub InsertAfterMethod()
Dim MyText As String
Dim MyRange As Object

Set MyRange = ActiveDocument.Range
MyText = "Jason Kaloyanides" '& vbCrLf & "Job Title" & vbCrLf & "Address"

' Selection Example:
Selection.InsertAfter (MyText)

' Range Example:
' (Inserts text at the current position of the insertion point.)
MyRange.Collapse
' MyRange.InsertAfter (MyText)
End Sub
 
S

Sue Mosher [MVP]

More details, please. Is Word the email editor, as it appears from the code?
Is there a particular reason why the user can't employ either of the
standard methods for inserting a signature with WordMail:

1) You can create an AutoText entry for each signature. You can then insert
them with the Insert | AutoText command.

2) Or, create multiple signatures the normal way (Tools | Options | Mail
Format) and make one the default. If you want to use a different signature
for the current message, right-click the signature that Outlook inserted
automatically. From the pop-up menu, select either the name of the signature
you want to use or E-mail Signature to create a new one. I personally prefer
this technique. This is also the technique you need to use if you want
Outlook 2003 to automatically change your signature when you switch accounts
on an unsent message.

If you call InsertAfter twice with different ranges, the text will be
inserted twice.
 
K

Ken Slovak - [MVP - Outlook]

Since you'd be inserting twice if the bottom lines weren't commented out it
makes sense that it would appear twice.

After inserting get the text you just inserted as a Range and use the Word
object model to set the font and whatever else you want to set on that text.
The Word groups would be best for any questions about how to use the Word
object model for that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top