David Zemens got your answer.
Here’s how to avoid repeating it.
Looking at this line:
For Each item In Worksheets("Collector").SlicerCaches("Slicer_RptDate").SlicerItems
If we made every statement explicit, it would look like this:
For Each item In Worksheets.Item("Collector").SlicerCaches.Item("Slicer_RptDate").SlicerItems
In other words:
Worksheets.Item("Collector") _
.SlicerCaches.Item("Slicer_RptDate") _
.SlicerItems
That’s a lot of member accesses for a single instruction.
By introducing intermediate variables…
Dim collectorSheet As Worksheet
Set collectorSheet = Worksheets("Collector")
Dim rptDateSlicerCache As SlicerCache
Set rptDateSlicerCache = collectorSheet.SlicerCaches("Slicer_RptDate") '*
For Each item In rptDateSlicerCache.SlicerItems
'...
Next
…you could have noticed while typing the line marked with a '*
comment, that IntelliSense doesn’t offer SlicerCaches
as a member of collectorSheet
.
Why? Because this:
Worksheets("Collector")
Returns an Object
— and from that point on, you’re on your own: IntelliSense can’t help you with autocompletion, because members of an Object
aren’t resolved until runtime.
By assigning that object to a Worksheet
variable, you give yourself compile-time checking, and avoid that pesky runtime error 438.
We already know that this is the most frustrating Microsoft Visual Basic Runtime Error 438 VBA issue which you are getting in day-to-day life, So today we are surely here going to show you some top best accessible methods and solutions and some tips and tricks to get rid out of it permanently from your Windows PC as well on your device too if you are facing on it also.
This shows an error code message like,
When you are running a Visual Basic or running the Microsoft Excel 2000, then you might get this error problem. This error occurs when you are trying to use variables for workbooks & worksheet names. This Microsoft Visual Basic Runtime Error 438 VBA may also happen when you are running a program in which a form is assigned to a variable & that variable is used to access a control on the form. This error includes your PC system crashes, virus infection or sometimes freezes too. It also starts when you are trying to execute the BW query. This error may occur if the installed AMD drivers out of date.
Causes of Microsoft Visual Basic Runtime Error 438 VBA Issue:
- Microsoft Visual Basic runtime
- Windows PC error issue
- An object does not support this property or method epaceengagement
So, here are some quick tips and tricks for efficiently fixing and resolve this type of Microsoft Visual Basic Runtime Error 438 VBA Windows PC Code issue from you permanently.
How to Fix & Solve Microsoft Visual Basic Runtime Error 438 VBA Issue
1. Disable the Enhanced Protected Mode from Internet Explorer –
- Open Internet Explorer
- Click on the tools option there, on the right side
- Click on the Internet Options there
- On the Advanced option,
- Uncheck the option box for “Enable Enhanced Protected Mode.”
It’s under the Security tab - Now, click on Apply to apply these settings
- Click on OK to save this configuration
- After completing, close all the tabs there
- That’s it, done
By disabling the Enhanced Protected Mode from your Internet Explorer browser can get rid out of this Microsoft Visual Basic Runtime Error 438 vba excel code problem.
2. Install an Automatic Repair Tool on your Windows PC –
- Go & Search for Automatic Repair Tool on the Internet
- Download it from there
- Now, Click on ‘RUN‘ & Install it
- Open it and use the automatic repair tool
- After finish, close the tab
- That’s it, done
By installing an automated repair tool on your Windows PC will fix this Runtime Error 438 excel vba access problem quickly from you.
3. Uninstall Microsoft Works Add-in on your Windows PC –
- Click on the Start menu
- Search for Control Panel or directly open it
- Open ‘Add or Remove Programs‘ tab there
- Click on the file location in the options tab
- On the Uninstall/Install option,
- Select the Words in Works Suite Add-in
- Again, click on the Add or Remove Programs there
- Follow the ON Screen instructions
- After completing, close all the tabs from there
- Restart your PC
- Load the Microsoft Word again
- That’s it, done
By uninstalling the Microsoft Works Add-in can get back you from this type of excel Runtime Error 438 VBA code issue.
4. Use a Registry Cleaner to Clean the Registry of your Windows –
Clean your registry by any registry cleaner software so that it can fix and solve this VBA Runtime Error 438 object doesn’t support access problem from your PC completely.
5. Reinstall the Drivers for the Device on your PC –
By Reinstalling the drivers for the device will fix your Visual Basic outlook Runtime Error 438 fix problem.
6. Run a Full Scan of your Windows PC for Malware or Virus –
- Go to the start menu
- Search or go to the “Microsoft Security Essentials” there
- Click on it and opens it there
- A Pop-up will open there
- Check the ‘Full‘ option there to scan thoroughly
- After, click on the ‘Scan Now‘ option to scan carefully
- After scanning, close the tab
- That’s it, done
By running a full scan of your PC can get rid out of this Runtime Error 438 word Excel VBA problems from your PC completely.
7. Create a System Restore Point on your Windows PC –
- Go to the start menu
- Search or go to the ‘System Restore.’
- Clicks on it and open it there
- After that, tick on the “Recommended settings” or ‘Select a restore point‘ there
- After selecting, click on the Next option there
- Now, follow the wizard
- After completing, close the tab
- That’s it, done
So by applying this method on your Microsoft Windows PC can quickly solve this VBA Runtime Error 438 excel MAC issue.
“ OR “
- Go to the start menu
- Search or go to the ‘System Properties.’
- Click on it and opens it
- After that, go to the “System Protection” option there
- Now, click on the “System Restore” option there
- & Create a Restore point there
- After completing, close the tab
- That’s it, done
Run a system restore and creating a new restore point by any of these two methods can solve this Visual Basic Runtime Error 438 ecw excel mac problem from your PC completely.
8. Troubleshoot & Run an Automatic Windows Repair on your PC –
- Go to the start menu
- Search or go to the PC settings there
- Click on the ‘Troubleshoot‘ option there
- After opening, click on the ‘Advanced options‘ there
- Then, click on the “Automatic Repair” option there
- After troubleshooting, close the tab
- That’s it, done
By running an automatic repair of your PC can get rid out of this Microsoft Visual Basic excel vba Runtime Error 438 problem from your PC.
9. Disable or Uninstall your Windows Antivirus Software on your PC –
By Disabling or uninstalling your antivirus software can quickly fix and solve this Runtime Error 438 object doesn’t support this property or method epaceengagement problem.
10. Restart your Windows PC [OPTIONAL] –
- Go to the Start menu
- Click on the right side of ‘Shutdown.’
- Click on Restart option there to restart
- That’s it, done
If this is your first time you have seen this stop error screen then by restarting your PC again will quickly fix this Microsoft Visual Basic Runtime Error 438 VBA problem.
These are the quick and the best way methods to get quickly rid out of this Microsoft Visual Basic Runtime Error 438 VBA Windows PC Code problem from you entirely. Hope these solutions will surely help you to get back from this Microsoft Visual Basic Runtime Error 438 VBA issue.
If you are facing or falling in this Microsoft Visual Basic Runtime Error 438 VBA Windows PC Code problem or any error problem, then comment down the error problem below so that we can fix and solve it too by our top best quick methods guides.
Home / VBA / VBA Object Doesn’t Support this Property or Method Error (Error 438)
VBA error 438 occurs when you try to use a property or method that does not support by that object. as you know all objects have some properties and methods that you can use but there could be a situation when using a property or method that does not apply to a particular object.
Let’s take an example to understand this: with the worksheet object there comes up a method to select the worksheet.
Now as you know you can activate a workbook but there is no method that you can use to select a workbook because you cannot select a workbook, you can only activate it.
So when you try to use this method with the workbook object you’ll get the runtime error 438. Even you can see this method is not in the list of properties and methods of the workbook object.
Now you can understand that it can be a mistake on the end of the person who writes the code and can be committed even if you are proficient in VBA.
Note: When you have written a code in the latest version of Microsoft Excel and now you try to run it in an older version, there’s could be a chance that that version doesn’t have a method or a property for the object you are using.
The best way to deal with this error 438 (Object Doesn’t Support this Property or Method) you need to be aware of the properties and methods that are supported by the object you are using.
When you define an object, you can see the list of all the properties and methods when you type a dot (.).
This list can help you to decide if the method you want to use is there or not. And if it’s not there you need to find a different way to write a code for the task that you want to accomplish. Otherwise, you can also open the object browser (F2) to see the properties and methods you have with an object.
More on VBA Errors
Subscript Out of Range (Error 9) | Type Mismatch (Error 13) | Runtime (Error 1004) | Object Required (Error 424) | Out of Memory (Error 7) | Invalid Procedure Call Or Argument (Error 5) | Overflow (Error 6) | Automation error (Error 440) | VBA Error 400
Return to VBA Code Examples
This article will demonstrate how to Fix VBA Error 438 – Object Doesn’t Support Property or Method.
Error 438 is a frequently occuring error in Excel VBA and is caused by either omitting a property or method when referring to an object, or by using a property or method that is not available to an object in the VBA code.
Check the VBA code to Fix Error 438
Let us examine the following code:
Sub RemoveWorksheet()
Dim wb As Workbook
Dim ws As Worksheet
Dim sheetName As String
sheetName = "Sheet 1"
Set wb = ActiveWorkbook
For Each ws In wb.Sheets
If ws = sheetName Then
wb.Sheets(sheetName).Delete
Exit For
End If
Next ws
End Sub
If we run this code, Error 438 will occur.
To resolve this issue, we click on Debug to see where the error is occurring.
This line of code is trying to equate the worksheet (depicted by the variable ws) to the sheet name. This is not possible as the worksheet is an object but the sheet name is a string so Error 438 is therefore returned.
To solve this, compare the string sheetName to the name property of the worksheet object:
ws.name = sheetName
Now the code runs without issue!
To show a list of all the properties or methods that are available to the worksheet object, we can type a dot (.) after the object.
This invokes the VBA Editor’s Intellisense feature. To make sure it’s turned on, in the Menu, select Tools > Options.
Make sure Auto List Members is checked and then click OK.
NOTE: This is usually on by default.
You can also find a list of all the Properties, Methods and Events for an Excel Object in the Object Browser.
In the Menu, select View > Object Browser or press F2 (See more VBE shortcuts).
A list of classes and objects will appear in the left hand side of the screen. If you click on the object you wish to use (eg: Workbook), a list of all the Properties, Methods and Events that that object supports will appear in the right hand side of the screen. (eg: Members of Workbook).
VBA Coding Made Easy
Stop searching for VBA code online. Learn more about AutoMacro — A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!
Learn More!
Permalink
Cannot retrieve contributors at this time
title | keywords | f1_keywords | ms.prod | ms.assetid | ms.date | ms.localizationpriority |
---|---|---|---|---|---|---|
Object doesn’t support this property or method (Error 438) |
vblr6.chm1011328 |
vblr6.chm1011328 |
office |
0fbab746-dc6d-b227-429a-1f56bb4ca448 |
06/08/2017 |
medium |
Not all objects support all properties and methods. This error has the following cause and solution:
-
You specified a method or property that doesn’t exist for this Automation object.
See the object’s documentation for more information on the object and check the spellings of properties and methods.
-
You specified a Friend procedure to be called late bound. The name of a Friend procedure must be known at compile time. It can’t appear in a late-bound call.
For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).
[!includeSupport and feedback]
- Remove From My Forums
-
Question
-
Good day
i seem to get a run-time error 438: Object doesn’t support this property or Method every time i try running my macro to automatically attach a PDF file called «Statement.xlsm»
Please assist, i am new at this VBA
here is my code:
Dim objOutlook As Object
Dim objNameSpace As Object
Dim objInbox As Object
Dim objMailItem As Object
Set objOutlook = CreateObject(«Outlook.Application»)
Set objNameSpace = objOutlook.GetNamespace(«MAPI»)
Set objInbox = objNameSpace.Folders(1)
Set objMailItem = objOutlook.CreateItem(0)
‘Declare a String variable for the recipient list, and an Integer variable
‘for the count of cells in column A that contain email addresses.
Dim strTo As String
Dim i As Integer
strTo = «»
i = 1‘Loop through the recipient email addresses to build a continuous string that separates recipient addresses by a semicolon and a space.
With Worksheets(«Statement») ‘change sheet name where list is kept.
Do
strTo = strTo & .Cells(i, 25).Value & «; «
i = i + 1
Loop Until IsEmpty(.Cells(i, 25))
End With
‘Remove the last two characters from the recipient string, which are
‘an unnedded semicolon and space.
strTo = Mid(strTo, 1, Len(strTo) — 2)
‘Display the email message with the attached active workbook.
With objMailItem
.To = strTo
.CC = «Eutychus@gcis.gov.za»
.Subject = «Media buying Statement»
.Body = _
«Hello everyone,» & Chr(10) & Chr(10) & _
«Here’s an example for attaching the active workbook» & Chr(10) & _
«to an email with multiple recipients.»Dim Attachment1 As String
Attachment1 = «http://ecms.gcis.gov.za/sites/docs/fin_mngmnt/47 Systems/4-7-3 Media Buying System/4-7-3-1 Media Buying Statements/Statement.xlsm.pdf»
.addAttachments
Attachment1 ‘(this is were is says i must
debug).Display ‘Change to Send if you want to just send it.
End With
‘Release object variables from system memory.
Set objOutlook = Nothing
Set objNameSpace = Nothing
Set objInbox = Nothing
Set objMailItem = NothingThank you in advance
Answers
-
The correct would be:
.Attachments.Add Attachment1
However, I couldn’t get the file in the URL indicated by Attachment1, because the URL http://ecms.gcis.gov.za/sites/docs/fin_mngmnt/47 Systems/4-7-3 Media Buying System/4-7-3-1 Media Buying Statements/Statement.xlsm.pdf doesn’t exist. Are you sure it is
correct?
Felipe Costa Gualberto — http://www.ambienteoffice.com.br
-
Proposed as answer by
Thursday, January 22, 2015 3:34 AM
-
Marked as answer by
Fei XueMicrosoft employee
Thursday, January 29, 2015 10:47 AM
-
Proposed as answer by
Dealing with Objects/Class, Methods, Properties and events can be very confusing at times when you are still new in VBA programming or even programming in general.
If you are not careful during your coding, you might generate errors like Run-time error ‘438’ — “Object doesn’t support this property or method.” In this article, you are going to learn the reason for the occurrence of this error and the best way to fix it. But before diving into the topic of interest, it is important define some terms.
Contents
- Understanding Objects, Methods, Properties and Events
- What is an object in VBA?
- What are Methods, Properties and Events?
- Reasons for the Run-time error 438: “Object doesn’t support this Property or Method”
- How to Fix the Error
Understanding Objects, Methods, Properties and Events
What is an object in VBA?
An object represents an element of an application, such as a worksheet, a cell, a chart, a form, or a report. VBA is categorized as an Object-Oriented Programming (OOP) language, that is why in VBA coding, you must identify an object before you can apply one of the object’s methods or change the value of one of its properties.
A collection is an object that contains several objects of the same type (usually but not always). In Microsoft Excel, for example, the Workbooks object contains all the open Workbook objects. In VBA, the Forms collection contains all the Form objects in an application.
What are Methods, Properties and Events?
Methods are actions that an object can perform. For example, Add is a method of the ListBox object, because it adds a new entry to a list box.
Properties are attributes of an object that defines one of the object’s characteristics, such as size, color, or screen location, or an aspect of its behavior, such as whether it is enabled/disabled, visible/hidden etc. To change the characteristics of an object, you change the values of its properties.
Each object has its own Methods and Properties. The diagram below gives some examples of methods, Properties and Events for the Form (UserForm) Object.
Events are actions recognized by an object, such as clicking the mouse or pressing a key, and for which you can write code to respond. Events can occur as a result of a user action or program code, or they can be triggered by the system.
The VBA Editor has an IntelliSense feature that displays the list of available properties and methods of an object when you type a period (.) after the object’s name.
Reasons for the Run-time error 438: “Object doesn’t support this Property or Method”
This error occurs when you are trying to use a method/property that the specified object does not support (i.e. it is not found in the list of available methods or properties of the object).
For instance, if you have a Workbook object and try to access the Range property, it will give you the 438 error since the Range
property belongs to the Sheets
object. You probably have a typo for the method name. For example, the following code results in an error.
Sub Error438() ActiveWorkbook.Select End Sub
The reason being that ActiveWorkbook
returns a Workbook
object. There is no Select method or property available for the Workbook
object, therefore an error occurs.
How to Fix the Error
The way to fix this error is just to determine which methods and properties are available for an object. To achieve that, do any of the following:
- Use the IntelliSense feature in the Visual Basic Editor. When you type a period (.) after a property or method in the Visual Basic Editor, a list of available properties and methods is displayed.
See also: User defined type not defined