Solved

PowerPoint VBA .SetShapesDefaultProperties not working for arrowheads

Posted on 2014-03-05
4
790 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 48

Accepted Solution

by:
Rgonzo1971 earned 400 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
probably too complicated then!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Is there a way to disable Outlook Data Integrity Check 4 54
IF OR formula Excel 8 29
Excel formula 5 50
Check version 13 60
Many programs have tried to outwit PowerPoint in terms of technology and skill. These programs, however, still lack several characteristics that PowerPoint has possessed from the start. Here's why PowerPoint replacements won't entirely work for desi…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
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…
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: …

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now