Default shape via VBA

Status
Not open for further replies.

eduperosa

Member
Outlook version
Outlook 365 64 bit
Email Account
Office 365 Exchange
I sent emails very often with images/screenshots where I want to mark something with a shape or arrow. The default rectangle shape of outlook is like this:
1641640718059.png

I would like to have a macro, assigned to keyboard shortcut, that formats the shape to something near this (provided that shape is selected):

1641640797205.png

I know there is the menu when you right-click the shape "Set as default shape", but once a new message is created the chosen default shape is lost.

Thank you all!
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
That would use word vba code - I don't have any code handy that does it, but there should be some code sample floating around the internet that does it in word - making it work in Outlook won't be difficult. Actually, you could probably record a macro doing it in word... (not all commands can be recorded).

I think you would need to select the image then run the macro to format it - not select a shape. so the macro will be hard coded to use the size of the image.
 

eduperosa

Member
Outlook version
Outlook 365 64 bit
Email Account
Office 365 Exchange
Found the solution:

Public Sub addShape()
Dim oShp As Word.Shape
Dim oSel As Word.Selection
Dim oWrd As Word.Application

Set oWrd = Application.ActiveInspector.WordEditor.Application
Set oSel = oWrd.Selection
Set oShp = oWrd.ActiveDocument.Shapes.addShape(msoShapeRectangle, getXCoord(oSel), getYCoord(oSel), 50, 25)

With oShp
.Fill.Visible = False
.Line.Visible = True
.Line.ForeColor.RGB = RGB(0, 176, 80)
.Line.Weight = 2.25
End With

Set oShp = Nothing
Set oSel = Nothing
Set oWrd = Nothing
End Sub

Private Function getXCoord(ByVal oSel As Word.Selection) As Double
getXCoord = oSel.Range.Information(wdHorizontalPositionRelativeToPage)

End Function

Private Function getYCoord(ByVal oSel As Word.Selection) As Double
getYCoord = oSel.Range.Information(wdVerticalPositionRelativeToPage)
End Function


References that I added to make it work:

Microsoft Scripting Runtime
Microsof Word 16.0 Object Library
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Perfect. It's pretty easy to convert word macros to work on email - DIM and Set the word objects and the necessary references.

It doesn't look like you are using the scripting runtime... does it work without that set.
 

eduperosa

Member
Outlook version
Outlook 365 64 bit
Email Account
Office 365 Exchange
You are right , just the Microsof Word 16.0 Object Library does the trick. At the end I added a button on the ribbon to run this macro.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
D Outlook 2021 Using vba code to delete all my spamfolders not only the default one. Outlook VBA and Custom Forms 0
B Outlook 2019 Custom Email form - Edit default email form Outlook VBA and Custom Forms 6
W Outlook 365 I am getting the "Either there is no default mail client" error when I try to send an email on excel Office 365 Using Outlook 1
P Outlook 2016 Change Paste Special Default Format Using Outlook 8
Geldner Tweak Junk Email Reporting tool to default to particular email on send? Using Outlook 3
P default font when sending email from browser Using Outlook 1
nmanikrishnan Auto-reply from default account Using Outlook 1
A force outlook to default to MY calendar Using Outlook 3
F VBA to move email from Non Default folder to Sub folders as per details given in excel file Outlook VBA and Custom Forms 11
e_a_g_l_e_p_i Outlook 2010 How to set default email address for website links Using Outlook 3
V Accepted meetings do not get the default reminder Using Outlook 0
Fozzie Bear Accepted Zoom Invites deleting without going into Default Calendar - Office 2016 Mac Using Outlook 3
W September 2020 - No Default Email Client message after Office Update Using Outlook 1
G Add to Outlook Contacts - Point to non-default contacts folder Using Outlook 0
R How to get the Items object of the default mailbox of a specific account in a multiple account Outlook? Outlook VBA and Custom Forms 0
R Auto display of new email does not work on non-default account Outlook VBA and Custom Forms 0
E How to display "Change Folder" in Change Default Email Delivery Location in Exchange Outlook 2016 Using Outlook 1
F Default font for notes in contacts Using Outlook 1
S Outlook 2010 unable to change default font Using Outlook 7
O How come default profile changed? Using Outlook 2
N How to set automatically the default or user defined Quickstyle Templates by Answer in Outlook Using Outlook 1
W Message class changes of a custom form changes to the default form Using Outlook 2
T Outlook changes default account Using Outlook 1
P how to remove unwanted PST file default categories assigned to many calendar entries Using Outlook 7
P Reading Pane (Reading Pain?) Default Setting Using Outlook 1
A Add to Outlook Contacts from email - default view Outlook VBA and Custom Forms 1
P Making iCloud the default calendar for Outlook 2016 Using Outlook 3
M Outlook 2016: Changing default font for Notes and Reading Pane Using Outlook 4
V Change default default save location to Quick Access Using Outlook 1
V Changing default date for task follow-up buttons Using Outlook 2
C Change default "Save Sent Item To" folder Outlook VBA and Custom Forms 9
V VBA when replying + Default Account Using Outlook 2
P Outlook.com account overrules default account Using Outlook.com accounts in Outlook 8
P Outlook 2016 Not Default Client Using Outlook 5
D Add all meeting rooms to the meeting request by default Outlook VBA and Custom Forms 0
Mark White VBScript Move sent mail to non-default folder Outlook VBA and Custom Forms 5
Mark White VBScript Move sent mail to non-default folder Outlook VBA and Custom Forms 0
N How to delete default folder "Contacts" (olFolderContacts) in a .pst file Using Outlook 8
D Default Send Account that Works? Using Outlook 0
T Changing default Mail Account in Outlook 2016 - POP3 Using Outlook 1
J Setting default address book Using Outlook 0
V importing appointments to non-default calendar? Using Outlook 1
H Change Default Email Account Using VBA Outlook VBA and Custom Forms 5
C Change default colors for conditional formatting Using Outlook 2
S Default Font in body of Task Using Outlook 0
Diane Poremsky Set Another Data File as Default When Using an Exchange Account Using Outlook 0
G Can't open .pst. Message could not access default folder (Outlook 2010 (.pst). Before that was backi Using Outlook 0
Diane Poremsky Shared Mailboxes and the Default 'Send From' Account Using Outlook 0
Diane Poremsky Working with VBA and non-default Outlook Folders Using Outlook 0
Diane Poremsky To Change the Default E-mail Program in Windows Using Outlook 0

Similar threads

Top