Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PowerPoint VBA .SetShapesDefaultProperties not working for arrowheads

Posted on 2014-03-05
4
Medium Priority
?
808 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
  • 2
4 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 1600 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 400 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
New style of hardware planning for Microsoft Exchange server.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

885 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