Link to home
Start Free TrialLog in
Avatar of Bryce Bassett
Bryce BassettFlag for United States of America

asked on

PowerPoint macro unintentionally disables all menu commands?

I've built an add-in for PowerPoint 2010.  One particular macro performs as expected, but when it is finished, my entire PowerPoint menu is disabled, not only my custom menu tab with my own macro buttons, but the entire menu.  I have to quit and re-launch PowerPoint to regain control.  

Can anybody see what may be causing this?

The macro creates a new layout for a custom type of slide, then opens a single-slide deck containing a few icons I need for this new layout, copies and pastes them to the layout I am building, closes the icon source deck, then creates a new slide based on the new layout just added.  I can navigate my new slide, add text, etc., but all menu commands are disabled.  They aren't greyed out.  The look normal, but I can't click on any of them.

Thanks for your help.

Sub add3colsnumb(ByVal mastno As Integer)

Dim myshp As Shape
Dim currentslide As Integer
Dim x As Integer
Dim dotbox As Shape
Dim layoutcount As Integer
Dim newslide As Slide
Dim newlayout As CustomLayout
Dim gridiconslide As Slide
Dim gridicondeck As Presentation
Dim gridiconaddress As String

If contentlibraryfolder = "" Then Call getcontentlibraryfolder
If contentlibraryfolder = "" Then DesignateFoldersForm.Show
If contentlibraryfolder = "" Then Exit Sub

layoutcount = ActivePresentation.Designs(mastno).SlideMaster.CustomLayouts.count

Set newlayout = ActivePresentation.Designs(mastno).SlideMaster.CustomLayouts.add(layoutcount + 1)

newlayout.Name = "Grid_" & Date & "_" & Time

Call AddHorizLine(newlayout, 33.08205, 239.0915, 266.1589, 239.0915)
Call AddHorizLine(newlayout, 284.2037, 239.0915, 517.2805, 239.0915)
Call AddHorizLine(newlayout, 535.3254, 239.0915, 768.4022, 239.0915)
Call AddTextBox(newlayout, 33.87315, 258.6399, 235.2491, 224.8062, "Lucida Sans", "16", 0, 1, 1, 3, "Click to add text")
Call AddTextBox(newlayout, 284.7016, 258.6399, 235.2491, 224.8062, "Lucida Sans", "16", 0, 1, 1, 3, "Click to add text")
Call AddTextBox(newlayout, 535.5301, 258.6399, 235.2491, 224.8062, "Lucida Sans", "16", 0, 1, 1, 3, "Click to add text")

gridiconaddress = contentlibraryfolder & "\Decks\gridicons-green.pptx"
Set gridicondeck = Application.Presentations.Open(gridiconaddress)
Set gridiconslide = gridicondeck.Slides(1)
    gridiconslide.Shapes("No13").Copy
        newlayout.Shapes.Paste
    gridiconslide.Shapes("No23").Copy
        newlayout.Shapes.Paste
    gridiconslide.Shapes("No33").Copy
        newlayout.Shapes.Paste
gridicondeck.Close

Call makesureslideselected

currentslide = ActiveWindow.View.Slide.SlideIndex

Set newslide = ActivePresentation.Slides.AddSlide(currentslide + 1, newlayout)

newslide.Select

End Sub

Open in new window

Avatar of Bryce Bassett
Bryce Bassett
Flag of United States of America image

ASKER

A bit more info:

If I toggle to another running program on my machine, then back to PowerPoint, I regain functionality of the ribbon, but next time I run any macro that creates a dialog box, I can't close it and am stuck again.  Have to force quite PowerPoint to get out of it.  

I know my trouble is coming in the part of the code where I open the second presentation and copy paste from it.  Works fine without that section which I just added yesterday.
ASKER CERTIFIED SOLUTION
Avatar of John Wilson
John Wilson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
JSR:

Thanks for chiming in.  I forgot to mention the most important fact, which is that I call this subroutine from within an open dialog box.  That seems to be why it is hanging up.  I changed my code to unload the dialog first, then call this sub, and it returns user control without any problems.  It doesn't answer why this happens, because as I said it works fine without the copy/paste section.  Without that, I can add slide after slide from within the dialog, then shut it when I want.  If you have other ideas, I'd be curious, but I'm out of time on this so I'll go with my solution and call this closed and give you the points.

I'd prefer not to post my whole file, but thanks for the reminder that you need all the pieces to unravel the mystery.  Thanks.