Running macro using buttons is causing problems with menus

%3CLINGO-SUB%20id%3D%22lingo-sub-1570132%22%20slang%3D%22en-US%22%3ERunning%20macro%20using%20buttons%20is%20causing%20problems%20with%20menus%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1570132%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%20Hopefully%20someone%20has%20seen%20this%20problem%20before.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20an%20Excel%20workbook%20which%20has%20some%20buttons%20(shapes)%20that%20have%20macros%20assigned%20to%20them%2C%20which%20switch%20between%20worksheets.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20run%20the%20macros%20from%20Visual%20Basic%20window%20(run%2C%20not%20step%20into)%20it%20works%20well.%20These%20exact%20same%20macros%20have%20been%20assigned%20to%20buttons%20in%20the%20worksheets.%20If%20I%20click%20them%20to%20switch%20between%20the%20sheets%2C%20after%20a%20few%20clicks%20the%20menus%20(such%20as%20changing%20font%2C%20clicking%20on%20my%20user%20information%2C%20sort%2Ffilter)%20become%20disabled.%20I%20am%20able%20to%20click%20on%20the%20menus%20but%20then%20a%20shadow%20like%20box%20of%20what%20should%20be%20displaying%20shows%20up%20(attached%20image%20showing%20when%20I%20click%20on%20my%20user%20info).%20And%20even%20more%20strange%2C%20it%20is%20just%20on%20certain%20sheets.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20can%20confirm%20the%20workbook%20and%20worksheets%20are%20not%20protected.%20Some%20of%20the%20worksheets%20have%20Worksheet_Change%20subs%20but%20I%20get%20the%20same%20problem%20on%20sheets%20that%20do%20not.%20The%20only%20ThisWorkbook%20sub%20I%20have%20relates%20to%20BeforeSave.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20help%20would%20be%20appreciated.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1570132%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1570869%22%20slang%3D%22en-US%22%3ERe%3A%20Running%20macro%20using%20buttons%20is%20causing%20problems%20with%20menus%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1570869%22%20slang%3D%22en-US%22%3ECan%20you%20share%20some%20of%20the%20relevant%20code%20please%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1571722%22%20slang%3D%22en-US%22%3ERe%3A%20Running%20macro%20using%20buttons%20is%20causing%20problems%20with%20menus%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1571722%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F22322%22%20target%3D%22_blank%22%3E%40Jan%20Karel%20Pieterse%3C%2FA%3E%26nbsp%3BMany%20thanks%20for%20your%20interest.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20made%20a%20scaled%20down%20version%20of%20my%20file%20which%20I%20have%20attached%2C%20which%20highlights%20the%20problem%20I%20am%20having.%20From%20my%20testing%2C%20it%20would%20suggest%20that%20Excel%20has%20a%20problem%20when%20switching%20sheets%20between%20visible%20and%20invisible%20when%20a%20macro%20is%20used%20to%20run%20using%20a%20button%20that%20is%20a%20shape%20or%20a%20form%20control.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20attached%2C%20the%20main%20sheet%20has%20multiple%20ways%20of%20switching%20to%20page%201%20and%20page%202.%20The%20first%20set%20of%20buttons%20are%20shapes.%20The%20second%20set%20form%20controls.%20The%20third%20set%20ActiveX%20controls.%20The%20fourth%20set%20are%20using%20the%20Worksheet_SelectionChange.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUse%20the%20Shapes%20or%20Form%20Controls%2C%20try%20clicking%20to%20go%20to%20page%201%2C%20then%20come%20back%2C%20then%20go%20to%20page%202%20and%20then%20come%20pack.%20You%20should%20find%20the%20many%20of%20the%20menu%20items%20are%20not%20working.%20But%20if%20you%20run%20the%20macros%20by%20using%20the%20ActiveX%20controls%2C%20the%26nbsp%3BWorksheet_SelectionChange%20or%20other%20manual%20ways%20of%20running%20the%20macros%2C%20I%20dont%20seem%20to%20have%20the%20same%20problems.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tested%26nbsp%3Bthe%20Shapes%20or%20Form%20Controls%20buttons%2C%20where%20the%20macro%20did%20not%20need%20to%20make%20the%20sheets%20visible%2Finvisible%20and%20the%20problem%20with%20the%20menus%20did%20NOT%20exist.%20Hence%20I%20think%20it%20relates%20to%20the%20changes%20to%20the%20visibility.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20using%20Windows%2010%2064%20bit%2C%20all%20updates%20done.%20Office365%2032bit%2C%20all%20updates%20done.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1572411%22%20slang%3D%22en-US%22%3ERe%3A%20Running%20macro%20using%20buttons%20is%20causing%20problems%20with%20menus%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1572411%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F621727%22%20target%3D%22_blank%22%3E%40joeSKH%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOne%20way%20that%20could%20happen%20is%20if%20you%20left%20click%20on%20a%20command%20button%2C%20but%20then%20move%20the%20mouse%20off%20the%20button%20before%20letting%20up%20the%20mouse%20button.%20Then%20the%20command%20button%20has%20the%20%22focus%22%20(you'll%20see%20a%20dotted%20line%20around%20the%20button%20indicating%20it%20is%20selected).%20When%20a%20button%20has%20the%20focus%2C%20ribbon%20functions%20that%20cannot%20be%20used%20on%20a%20button%20are%20grayed%20out.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20also%20noticed%20that%2C%20after%20clicking%20around%20for%20a%20little%20bit%2C%20when%20I%20click%20on%20the%20%22Page%202%22%20blue%20rectangle%20on%20the%20Main%20worksheet%20that%20the%20command%20button%20on%20Page%202%20is%20the%20image%20of%20the%20Page%201%20command%20button%20(see%20Capture1).%20The%20command%20button%20for%20Page%202%20is%20there%2C%20but%20you%20have%20to%20left%20click%20where%20it's%20supposed%20to%20be%20(Column%20I)%20and%20then%20it%20shows%20up%20(see%20Capture%202%2C%20which%20also%20shows%20the%20ribbon%20grayed%20out%20because%20the%20command%20button%20has%20the%20focus).%20Not%26nbsp%3B%20sure%20why%20it's%20doing%20that%2C%20though.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1573057%22%20slang%3D%22en-US%22%3ERe%3A%20Running%20macro%20using%20buttons%20is%20causing%20problems%20with%20menus%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1573057%22%20slang%3D%22en-US%22%3EI%20don't%20see%20any%20weirdness%20on%20my%20end.%20It%20all%20works%20as%20expected.%3CBR%20%2F%3EWhat%20happens%20if%20you%20launch%20Excel%20in%20safe%20mode%20and%20then%20try%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1574122%22%20slang%3D%22en-US%22%3ERe%3A%20Running%20macro%20using%20buttons%20is%20causing%20problems%20with%20menus%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1574122%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20safe%20mode%20I%20do%20not%20experience%20the%20issue.%26nbsp%3B%20I%20was%20able%20to%20replicate%20the%20same%20problem%20on%20my%20fellow%20employees%20computers%2C%20but%20they%20would%20have%20a%20very%20similar%20set-up%20to%20mine.%20We%20dont%20have%20any%20add%20ins%20active%20except%20for%20Acrobat%20PDF%20Maker%20and%20based%20on%20my%20reading%2C%20with%20it%20being%20a%20COM%20Add%20in%20it%20is%20not%20excluded%20by%20safe%20mode.%20The%20only%20settings%20that%20we%20have%20changed%20from%20default%20are%20Trust%20Center%20settings%20above%20ActiveX%20and%20Macros%20-%20I%20tried%20changing%20these%20back%20to%20default%20but%20it%20had%20no%20effect.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20an%20old%20laptop%20with%20Excel%202010%20and%20it%20did%20not%20have%20the%20problem.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi, Hopefully someone has seen this problem before.

 

I have an Excel workbook which has some buttons (shapes) that have macros assigned to them, which switch between worksheets. 

 

If I run the macros from Visual Basic window (run, not step into) it works well. These exact same macros have been assigned to buttons in the worksheets. If I click them to switch between the sheets, after a few clicks the menus (such as changing font, clicking on my user information, sort/filter) become disabled. I am able to click on the menus but then a shadow like box of what should be displaying shows up (attached image showing when I click on my user info). And even more strange, it is just on certain sheets.

 

I can confirm the workbook and worksheets are not protected. Some of the worksheets have Worksheet_Change subs but I get the same problem on sheets that do not. The only ThisWorkbook sub I have relates to BeforeSave. 

 

Any help would be appreciated. 

5 Replies
Highlighted
Can you share some of the relevant code please?
Highlighted

@Jan Karel Pieterse Many thanks for your interest. 

 

I have made a scaled down version of my file which I have attached, which highlights the problem I am having. From my testing, it would suggest that Excel has a problem when switching sheets between visible and invisible when a macro is used to run using a button that is a shape or a form control.

 

In the attached, the main sheet has multiple ways of switching to page 1 and page 2. The first set of buttons are shapes. The second set form controls. The third set ActiveX controls. The fourth set are using the Worksheet_SelectionChange.

 

Use the Shapes or Form Controls, try clicking to go to page 1, then come back, then go to page 2 and then come pack. You should find the many of the menu items are not working. But if you run the macros by using the ActiveX controls, the Worksheet_SelectionChange or other manual ways of running the macros, I dont seem to have the same problems.

 

I tested the Shapes or Form Controls buttons, where the macro did not need to make the sheets visible/invisible and the problem with the menus did NOT exist. Hence I think it relates to the changes to the visibility. 

 

I am using Windows 10 64 bit, all updates done. Office365 32bit, all updates done. 

Highlighted

@joeSKH 

 

One way that could happen is if you left click on a command button, but then move the mouse off the button before letting up the mouse button. Then the command button has the "focus" (you'll see a dotted line around the button indicating it is selected). When a button has the focus, ribbon functions that cannot be used on a button are grayed out.

 

I also noticed that, after clicking around for a little bit, when I click on the "Page 2" blue rectangle on the Main worksheet that the command button on Page 2 is the image of the Page 1 command button (see Capture1). The command button for Page 2 is there, but you have to left click where it's supposed to be (Column I) and then it shows up (see Capture 2, which also shows the ribbon grayed out because the command button has the focus). Not  sure why it's doing that, though.

Highlighted
I don't see any weirdness on my end. It all works as expected.
What happens if you launch Excel in safe mode and then try?
Highlighted

In safe mode I do not experience the issue.  I was able to replicate the same problem on my fellow employees computers, but they would have a very similar set-up to mine. We dont have any add ins active except for Acrobat PDF Maker and based on my reading, with it being a COM Add in it is not excluded by safe mode. The only settings that we have changed from default are Trust Center settings above ActiveX and Macros - I tried changing these back to default but it had no effect. 

 

I have an old laptop with Excel 2010 and it did not have the problem.