Solved

PowerPoint VBA .SetShapesDefaultProperties not working for arrowheads

Posted on 2014-03-05
4
793 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
  • 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
This article will show you how to use shortcut menus in the Access run-time environment.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

791 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