Jamie Garroch (MVP)
asked on
PowerPoint SendKeys behaviour with 2007 and SmartArt
I don't like using SendKeys but in this PowerPoint 2007 case there is no other choice AFAIK.
I am trying to turn the outlines off for the shapes within a SmartArt object after it's been inserted into a slide by the user.
Since 2007 doesn't support the SmartArt object model, I have to use GroupItems. But even then, the GroupItems properties are read only. So my fallback plan is to replicate the user behaviour by using SendKeys to tab through each shape in the SmartArt group and send the sequence to turn off the line.
I'm using the app event WindowSelectionChange(ByVa l Sel As Selection) to detect the object insertion and then run a selection checking procedure (selection type / count / shape type etc.) before running this code to do the SmartArt formatting:
Now, if I manually run the above code via a test macro using Alt+F8 to run it when a SmartArt object is selected, the formatting changes are applied.
But when I run it programmatically as intended via the app event handler, it fails and the paragraph dialog box appears instead. The key sequence for that is Alt+H+PG.
I've also tried doing things before running the above code such as "refreshing" the slide by going to slide n+1 and then back, inserting DoEvents, waiting for a fews seconds and even interrupting the code with a msgbox. Nothing has worked.
How can I get SendKeys to work in this situation?
I am trying to turn the outlines off for the shapes within a SmartArt object after it's been inserted into a slide by the user.
Since 2007 doesn't support the SmartArt object model, I have to use GroupItems. But even then, the GroupItems properties are read only. So my fallback plan is to replicate the user behaviour by using SendKeys to tab through each shape in the SmartArt group and send the sequence to turn off the line.
I'm using the app event WindowSelectionChange(ByVa
' Loop through each shape in the group and turn the outline off
iShapes = ActiveWindow.Selection.ShapeRange(1).GroupItems.Count
For counter = 1 To iShapes
SendKeys ("{TAB}"), True ' Tab
SendKeys ("%"), True ' Alt
SendKeys ("JO"), True ' Context sensitive Format tab
SendKeys ("SO"), True ' Shape Outline
SendKeys ("N"), True ' None
Next
Now, if I manually run the above code via a test macro using Alt+F8 to run it when a SmartArt object is selected, the formatting changes are applied.
But when I run it programmatically as intended via the app event handler, it fails and the paragraph dialog box appears instead. The key sequence for that is Alt+H+PG.
I've also tried doing things before running the above code such as "refreshing" the slide by going to slide n+1 and then back, inserting DoEvents, waiting for a fews seconds and even interrupting the code with a msgbox. Nothing has worked.
How can I get SendKeys to work in this situation?
Hi,
pls try this workaround
pls try this workaround
Sub Macro1()
'Loop through each shape in the group and turn the outline off
For Each Item In ActiveWindow.Selection.ShapeRange(1).GroupItems
' Item.Line.Visible = msoFalse ' not working
Item.Line.Weight = 0
Item.Line.Transparency = 1
Next
'
End Sub
Regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
It's always going to be ropey though.