0

I have an uncommon issue. I have an Excel file with macros. On all computers it was installed Office 2010 and everything worked fine, but a few days ago every computer was upgraded to Office 2013. In code, at some point I enable or disable some buttons based on some criterias.

 ThisWorkbook.Worksheets("Lab Orders").OLEObjects("CommandButton1").Enabled = False

On some computers this works fine , but on other computers this button is shown as enabled, and if the user clicks the button nothing happens, not even the animation where the the button is pressed, so it cannot execute the code behind. It's like an image. Any leads, or reasons why this is happening only on certain computers ? I have this problem after the Office got upgraded. PS. All computers are in the same domain.

LATER EDIT

I changed the code line

ThisWorkbook.Worksheets("Lab Orders").CommandButton1.Enabled = True

and now I get this error: 438 at this row (I debbuged the file on a computer where this file does not work)

3 Answers 3

1

I suspect it's the issue with the latest Office updates - see if this fixes it: http://excelmatters.com/2014/12/10/office-update-breaks-activex-controls/

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! This was the cause. I removed those files then my file worked again.
0

On all computers where you have the problem, check the box "Trust access to the VBA project object model" located in Options/Trust Center/Macro Settings

(Note that this will only apply to Excel, and if you are having the same problems on other MS Office softwares, you should do the same on them as well)

If that's still not working, read and apply all the checks on this page : https://support.office.com/en-gb/article/Enable-or-disable-macros-in-Office-files-12b036fd-d140-4e74-b45e-16fed1a7e5c6

Comments

0

Did not fit as a comment, so: If I understand you correctly, some computers show the button enabled, while in fact it is disabled, right?
In this case it's normal no button press animation "visibly happens" as Windows knows the button was programmatically disabled.
The same thing happens if you hook a window (which has buttons on it) and send any button a WM to show itself as if it was enabled (while in fact it is not).

The reason it seems enabled on some computers may vary, most probably it's video card and/or driver 'issue', or some "strange alignment" (that particular OS with that particular graphics card & driver and DirectX, as well as those 'special' OLE settings, etc).
In both cases, the screen area don't get "refreshed" (invalidated) after the button was disabled - so it seems enabled and gets "repainted" only when there was some user interaction around it. "Lazy redraw", so to speak :)

What one can do is, if it happens to be a serious issue, to find a way on one of these computers to get the button visibly disabled with some 'workaround' (e.g. changing button text after it was disabled -maybe even to exactly the same text-, or move it 1 pixel away and back, call InvalidateRect on it, etc), and apply that solution to your Excel macro.


UPDATE after reading asker's comment:
Oh I see. This could happen if the buttons are in a control array. The issue in this case, however should be present on all computers... Strange.
Anyway. Try to test the buttons' Index property to see if they are part of a control array, just to be sure. If yes:
a) remove them from the array and create buttons "independent" from each other
b) create a bool array and store there enabled/disabled status and write a function that updates buttons' text color property & handles button click event ignore/accept

2 Comments

My problem is that all my buttons (enabled ones) from that sheet are "kind of blocked". If I disable a button, the button aspect changes and is displayed as it should be displayed (grey text), but buttons that are enabled, are my problem because I cannot click them.
@SparX23 updated feedback. In this case, though, note that I'm guessing here. On the other hand, Rory's answer seems legit :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.