Solved

PowerPoint VBA .SetShapesDefaultProperties not working for arrowheads

Posted on 2014-03-05
4
804 Views
Last Modified: 2014-03-07
Experts:

You guys are always so good at these obscure programming questions.  Here another one.

I'm providing a command button on a PowerPoint Add-in toolbar that helps the user draw a stylized line with arrowhead in the proper thickness, dash style, color, etc.

I accomplish this by having VBA draw a small dummy line, stylizing it as desired, setting its properties as the default shape properties, then deleting it.  Then I use SendKeys to put the user into drawing mode with arrow selected.  

Works fine except that the endArrowHead properties do not seem to "stick" and I get the default arrowhead.  Try out my code and you'll see what I mean.  
Sub DrawHorizLineWithArrowhead()

Dim myline As Shape
Dim currentslide As Slide

Set currentslide = ActivePresentation.Slides(ActiveWindow.View.Slide.SlideIndex)

Set myline = currentslide.Shapes.AddLine(10, 10, 50, 50)
With myline.Line
    .Weight = 2
    .DashStyle = msoLineRoundDot
    .DashStyle = msoLineSysDot
    .ForeColor.ObjectThemeColor = 3
    .ForeColor.Brightness = 0.4
    .BeginArrowheadStyle = msoArrowheadOval
    .EndArrowheadStyle = msoArrowheadTriangle
    .EndArrowheadWidth = msoArrowheadWide
    .EndArrowheadLength = msoArrowheadLong
End With

myline.SetShapesDefaultProperties
myline.Delete

SendKeys ("%")
SendKeys ("N")
SendKeys ("SH")
SendKeys ("{DOWN}{DOWN}{RIGHT}{ENTER}")

End Sub

Open in new window

Anybody know why the arrowhead styling is not being saved along with the other default properties?  I get the same result if I manually right-click my dummy line and "save as default line" so I think it's a PowerPoint issue, not a VBA issue.  Is there a workaround?  THANKS.
0
Comment
Question by:Bryce Bassett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 400 total points
ID: 39908894
HI,

If you select the line instead of the arrow you should get the result you want.
SendKeys ("{DOWN}{DOWN}{ENTER}")

Open in new window


Regards
0
 
LVL 23

Assisted Solution

by:JSRWilson
JSRWilson earned 100 total points
ID: 39908958
But all lines will be set to this default.

Since you are writing an Add In I would trap the select event and use it to detect a new arrow being added and set the properties accordingly. You could have a check box on the ribbon to set whether it was the normal default or you new style.
0
 

Author Comment

by:Bryce Bassett
ID: 39910344
Thanks, Rgonzo1971.  Your solution works.   I don't quite understand why but that's not important.

JSR, I was intentionally changing the default line, but on further thought, I might want to leave it alone.  

I'm a self-taught VBA programmer so I'm struggling a bit with your suggestion to "trap the select event and use it to detect a new arrow being added and set the properties accordingly."   Can you spell out for me how I would code this?    What I'm trying to accomplish, as you can see, is to make it so the NEXT line drawn has the correct properties.  If after drawing that line, successive lines revert to the default, that would be ideal, but I don't get exactly how to do that.  

Thanks both.
0
 
LVL 23

Expert Comment

by:JSRWilson
ID: 39911809
probably too complicated then!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question