Command Button to insert Email Signature

Status
Not open for further replies.
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.

Sue Mosher

"JK" <jasonk at necoffeeco dot com> wrote in message

news:534CF323-9EEA-4165-B05C-D81055FD30E1@microsoft.com...
> 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
 
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.

"JK" <jasonk at necoffeeco dot com> wrote in message

news:534CF323-9EEA-4165-B05C-D81055FD30E1@microsoft.com...
> 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
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
M VbScript for Command Button on Contacts Custom Form Using Outlook 1
J Command Button to stamp a date and time in a textbox in Outlook 2016 Outlook VBA and Custom Forms 3
D Command Button code will not execute. Any suggestions Please. Outlook VBA and Custom Forms 2
S Problem running Command button code Outlook VBA and Custom Forms 2
S Code behind form command button Using Outlook 2
M Open new outlook form from within existing outlook form using command button Using Outlook 4
A Command Button Controls Outlook VBA and Custom Forms 6
Z Command button no longer firing after sending custom form over ema Outlook VBA and Custom Forms 1
U Customized Command Button Outlook VBA and Custom Forms 3
S Command Button_Click action on Item/Reminder Outlook VBA and Custom Forms 2
J OUTLOOK 2016 FILE STORAGE WHERE COMMAND Using Outlook 12
D Custom Form Accept and Reject Command buttons Outlook VBA and Custom Forms 2
Dr. Demento Outlook version of Excel command? Using Outlook 5
L Outlook Data Files command not working in the quick access bar Using Outlook 1
R Missing Backup command in File menu after installing pfback.exe Using Outlook 2
S Exchange Management Shell closes on command failure Exchange Server Administration 5
P "open" command in right click context menu Outlook Wishlist 4
M "New Appointment from Contact" command missing from Outlook 2003 Using Outlook 1
J Executing Ribbon Command from Code Outlook 2010 Outlook VBA and Custom Forms 3
S How to call a procedure from a custom command bar in Outlook 2007 Outlook VBA and Custom Forms 1
L Outlook 2003 - Set Virables via command line Outlook VBA and Custom Forms 1
T Command bar IDs for Outlook 2007 Using Outlook 2
D Locking Command Bar positions between sessions Outlook Wishlist 0
T Is there a VBA command to Redirect your Emails? Outlook VBA and Custom Forms 1
A How to access command bars in outlook 2007 Outlook VBA and Custom Forms 3
5 How to get Outlook's command line parameters? Outlook VBA and Custom Forms 1
witzker HowTo start a macro with an Button in OL contact form Outlook VBA and Custom Forms 12
R Follow up button doesn't working neither the reminders in BCM BCM (Business Contact Manager) 0
Eike Move mails via macro triggered by the click of a button? Outlook VBA and Custom Forms 0
K Disabling import/export button to restrict PST creation Using Outlook 3
N Which Button Was Clicked on the Ribbonbar Menu Outlook VBA and Custom Forms 2
E Can't accept or decline task (no button appears) Using Outlook 2
Q Prompt button to auto turn on Out of Office Outlook VBA and Custom Forms 3
C iCloud Setting missing Outlook tab and Outlook missing the iCloud refresh button Using Outlook 4
witzker Outlook 2010 Insert Date & Time at the button of an OL contactform in red Using Outlook 2
S How to set up button in ribbon for individual Quick Steps Using Outlook 1
C Custom Outlook Form - Populate Information from Radio Button / Check Box Using Outlook 0
A ScanPST finding errors but no Repair button Using Outlook 2
N Creating a button or link to a form in the Organizational Forms Library Outlook VBA and Custom Forms 3
J Execute Add-In Button from VBA Outlook 2016 Outlook VBA and Custom Forms 1
S Reminder Dialog Open Button Using Outlook 2
Wayne Dardis Calling Ribbon Button in Outlook 2016 Outlook VBA and Custom Forms 6
Tanja Östrand Outlook 2016 - Create Macro button to add text in Subject Outlook VBA and Custom Forms 1
R Categorize Button in Quick Access Toolbar Disappears on New Email Using Outlook 1
E Button to change subject Outlook VBA and Custom Forms 1
S Shortcut/button to a Calendar Group Using Outlook 0
soadfan Enable all rules from toolbar button? Outlook VBA and Custom Forms 3
I Creating meeting invite with disabled tentative button Outlook VBA and Custom Forms 5
Diane Poremsky Contacts are missing when you click the To button New Slipstick.com Articles 0
T Unable to 'Upload a file' using popup 'Browse' button Using Outlook 0

Similar threads

Top