PDA

View Full Version : [SOLVED:] Object doesn't support this property or method



Mister_joe
12-23-2014, 04:22 PM
Hi folks,
I have an embarrassing challenge. I wrote some VBA codes in January 2014. The program has run without problems since January until 17 December 2014 when it started spewing error message.

The following lines of codes used to run without problem, but they do not run anymore after I updated the Office 2007 in my laptop:


If TypeName(obj.Object) = "CommandButton" Then
If obj.Name = "CommandButton1" Then
obj.Name = "btnCalculateBalance"
ElseIf obj.Name = "CommandButton2" Then
obj.Name = "btnCancelBalance"
ElseIf obj.Name = "CommandButton3" Then
obj.Name = "btnClearAll"
End If
End If


Code like the following doesn't work anymore:


Sheets(1).btnCalculateBalance.Enabled = False

The error message says "Run-time error 438, Object doesn't support this property or method."

I am perplexed, for example, that command such as Sheets(1).btnCalculateBalance.Enabled = False would say that the command button object does not support the Enable property.

Please, if you have had this experience or knows what is happening, do oblige me with an explanation. Thanks!

GTO
12-23-2014, 05:43 PM
Hi Joe,

Given the default names of CommandButton1 (and so on) and the expected return of TypeName, I am guessing your code looks something like:


Sub example()
Dim obj As OLEObject
For Each obj In Sheet1.OLEObjects '<--- Note: I used the sheet's CodeName
If TypeName(obj.Object) = "CommandButton" Then
If obj.Name = "CommandButton1" Then
obj.Name = "btnCalculateBalance"
ElseIf obj.Name = "CommandButton2" Then
obj.Name = "btnCancelBalance"
ElseIf obj.Name = "CommandButton3" Then
obj.Name = "btnClearAll"
End If
End If
Next

End Sub

...at least as far as obj representing an OLEObject. Thus - I am betting the buttons are ActiveX controls, and these are busted...

If I have that right, please see Here (http://excelmatters.com/2014/12/10/office-update-breaks-activex-controls) (Props to Aflatoon!)for a possible solution.

Hope that helps,

Mark

SamT
12-23-2014, 05:49 PM
We have seen several reports of S Office Updates causing problems lately.

Here are some possible solutions from around the Web.

http://dailydoseofexcel.com/archives/2014/12/11/recent-update-of-office-causes-problems-with-activex-controls/

http://spreadsheet1.com/ms14-082-kb2553154-update-breaks-activex-controls-in-excel.html

https://social.technet.microsoft.com/Forums/en-US/b8f0af82-0bb8-4799-aa62-1dbcbc5b7742/excel-2010-macros-does-not-work-after-updates-9dec2014?forum=excel

http://answers.microsoft.com/en-us/office/forum/office_2007-excel/office-security-update-kb2596927-ms14-082-dec-9/07a21df1-d89a-461b-8fbd-e6589dec213a


Consider:
In the future, set your computer to "Notify me of updates, but do not automatically download or install them." When notified of available updates, use the System Restore program in the Accessories >> System Tools folder to create a Restore Point.

Install the updates. Extensively test all your office programs that use VBA and/ or custom controls. If there is a problem, Restore your computer and reinstall the updates one at a time until you find the one(s) that caused the problem(s). Restore the computer again and reinstall all the updates except the one(s) that break your computer.

Mister_joe
12-25-2014, 03:56 PM
Apology for coming back delayed. I had traveled to a far flung location for Christmas. Quite honestly, I did not have a merry Christmas because the problem was always on my mind. I developed the macro and it had always run without errors. Suddenly, I could not run it anymore and still it continued to run in other users computers. Really, it was embarrassing. My mind went bland for awhile until I realized that help may just be a few clicks away - VBAExpress!.

Thanks a lot GTO and SamT. The fix worked like magic.