Solved

PowerPoint VBA .SetShapesDefaultProperties not working for arrowheads

Posted on 2014-03-05
4
797 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:versatilebb
[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 50

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:versatilebb
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

735 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