Summary:
In this post, I have included the complete information about Excel runtime error 1004. Besides that I have presented some best fixes to resolve runtime error 1004 effortlessly.
To fix Runtime Error 1004 in Excel you can take initiatives like uninstalling Microsoft Work, creating a new Excel template, or deleting The “GWXL97.XLA” File. If you don’t have any idea on how to apply these methods then go through this post.
Here in this article, we are going to discuss different types of VBA runtime error 1004 in Excel along with their fixes.
What Is Runtime Error 1004 In VBA Excel?
Excel error 1004 is one such annoying runtime error that mainly encounters while working with the Excel file. Or while trying to generate a Macro in Excel document and as a result, you are unable to do anything in your workbook.
This error may cause serious trouble while you are working with Visual Basic Applications and can crash your program or your system or in some cases, it freezes for some time. This error is faced by any versions of MS Excel such as Excel 2007/2010/2013/2016/2019 as well.
To recover lost Excel data, we recommend this tool:
This software will prevent Excel workbook data such as BI data, financial reports & other analytical information from corruption and data loss. With this software you can rebuild corrupt Excel files and restore every single visual representation & dataset to its original, intact state in 3 easy steps:
- Download Excel File Repair Tool rated Excellent by Softpedia, Softonic & CNET.
- Select the corrupt Excel file (XLS, XLSX) & click Repair to initiate the repair process.
- Preview the repaired files and click Save File to save the files at desired location.
Error Detail:
Error Code: run-time error 1004
Description: Application or object-defined error
Screenshot Of The Error:
Don’t worry you can fix this Microsoft Visual Basic runtime error 1004, just by following the steps mentioned in this post. But before approaching the fixes section catch more information regarding runtime error 1004.
Excel VBA Run Time Error 1004 Along With The Fixes
The lists of error messages associated with this Excel error 1004 are:
- VB: run-time error ‘1004’: Application-defined or object-defined error
- Excel VBA Runtime error 1004 “Select method of Range class failed”
- runtime error 1004 method range of object _global failed visual basic
- Excel macro “Run-time error ‘1004″
- Runtime error 1004 method open of object workbooks failed
- Run time error ‘1004’: Method ‘Ranger’ of Object’ Worksheet’ Failed
- Save As VBA run time Error 1004: Application defined or object defined error
Let’s discuss each of them one by one…!
#1 – VBA Run Time Error 1004: That Name is already taken. Try a different One
This VBA Run Time Error 1004 in Excel mainly occurs at the time of renaming the sheet.
If a worksheet with the same name already exists but still you are assigning that name to some other worksheet. In that case, VBA will throw the run time error 1004 along with the message: “The Name is Already Taken. Try a different one.”
Solution: You can fix this error code by renaming your Excel sheet.
#2 – VBA Run Time Error 1004: Method “Range” of object’ _ Global’ failed
This VBA error code mainly occurs when someone tries to access the object range with wrong spelling or which doesn’t exist in the worksheet.
Suppose, you have named the cells range as “Headings,” but if you incorrectly mention the named range then obviously you will get the Run Time Error 1004: Method “Range” of object’ _ Global’ failed error.
Solution: So before running the code properly check the name of the range.
# 3 – VBA Run Time Error 1004: Select Method of Range class failed
This error code occurs when someone tries to choose the cells from a non-active sheet.
Let’s understand with this an example:
Suppose you have selected cells from A1 to A5 from the Sheet1 worksheet. Whereas, your present active worksheet is Sheet2.
At that time it’s obvious to encounter Run Time Error 1004: Select Method of Range class failed.
Solution: To fix this, you need to activate the worksheet before selecting cells of it.
#4 – VBA Runtime Error 1004 method open of object workbooks failed
This specific run time Error 1004 arises when someone tries to open an Excel workbook having the same workbook name that is already open.
In that case, it’s quite common to encounter VBA Runtime Error 1004 method open of object workbooks failed.
Solution: Well to fix this, first of all close the already opened documents having a similar name.
#5 – VBA Runtime Error 1004 Method Sorry We Couldn’t Find:
The main reason behind the occurrence of this VBA error in Excel is due to renaming, shifting, or deletion of the mentioned path.
The reason behind this can be the wrong assigned path or file name with extension.
When your assigned code fails to fetch a file within your mentioned folder path. Then you will definitely get the runtime Error 1004 method. Sorry, and We couldn’t find it.
Solution: make a proper check across the given path or file name.
#6 – VBA Runtime Error 1004 Activate method range class failed
Behind this error, the reason can be activating the cells range without activating the Excel worksheet.
This specific error is quite very similar to the one which we have already discussed above i.e Run Time Error 1004: Select Method of Range class failed.
Solution: To fix this, you need to activate your excel sheet first and then activate the sheet cells. However, it is not possible to activate the cell of a sheet without activating the worksheet.
Why This Visual Basic Runtime Error 1004 Occurs?
Follow the reasons behind getting the run time error 1004:
- Due to corruption in the desktop icon for MS Excel.
- Conflict with other programs while opening VBA Excel file.
- When filtered data is copied and then pasted into MS Office Excel workbook.
- Due to application or object-defined error.
- A range value is set programmatically with a collection of large strings.
Well, these are common reasons behind getting the VBA runtime error 1004, now know how to fix it. Here we have described both the manual as well as automatic solution to fix the run time error 1004 in Excel 2016 and 2013. In case you are not able to fix the error manually then make use of the automatic MS Excel Repair Tool to fix the error automatically.
Follow the steps given below to fix Excel run time error 1004 :
1: Uninstall Microsoft Work
2: Create New Excel Template
3: Delete The “GWXL97.XLA” File
Method 1: Uninstall Microsoft Work
1. Go to the Task Manager and stop the entire running programs.
2. Then go to Start menu > and select Control Panel.
3. Next, in the Control Panel select Add or Remove Program.
4. Here, you will get the list of programs that are currently installed on your PC, and then from the list select Microsoft Work.
5. And click on uninstall to remove it from the PC.
It is also important to scan your system for viruses or malware, as this corrupts the files and important documents. You can make use of the best antivirus program to remove malware and also get rid of the runtime error 1004.
Method 2: Create New Excel Template
Another very simple method to fix Excel runtime error 1004 is by putting a new Excel worksheet file within a template. Instead of copying or duplicating the existing worksheet.
Here is the complete step on how to perform this task.
1.Start your Excel application.
2. Make a fresh new Excel workbook, after then delete the entire sheets present on it leaving only a single one.
3. Now format the workbook as per your need or like the way you want to design in your default template.
4. Excel 2003 user: Tap to the File>Save As option
OR Excel 2007 or latest versions: Tap to the Microsoft Office button after then hit the Save As option.
5. Now in the field of File name, assign name for your template.
6. On the side of Save as type there is a small arrow key, make a tap on it. From the opened drop menu
- Excel 2003 users have to choose the Excel Template (.xlt)
- And Excel 2007 or later version have to choose the Excel Template (.xltx)
7. Tap to the Save.
8. After the successful creation of the template, now you can programmatically insert it by making use of the following code:
Add Type:=pathfilename
Remarks:
From the above code, you have to replace the pathfilename with the complete path including the file name. For assigning the exact location of the sheet template you have just created.
Method 3: Delete The “GWXL97.XLA” File
Follow another manual method to fix Excel Runtime Error 1004:
1. Right-click on the start menu.
2. Then select the Explore option.
3. Then open the following directory – C:Program FilesMSOfficeOfficeXLSTART
4. Here you need to delete “GWXL97.XLA” file
5. And open the Excel after closing the explorer
You would find that the program is running fine without a runtime error. But if you are still facing the error then make use of the automatic MS Excel Repair Tool, to fix the error easily.
Automatic Solution: MS Excel Repair Tool
MS Excel Repair Tool is a professional recommended solution to easily repair both .xls and .xlsx file. It supports several files in one repair cycle. It is a unique tool that can repair multiple corrupted Excel files at one time and also recover everything included charts, cell comments, worksheet properties, and other data. This can recover the corrupt Excel file to a new blank file. It is extremely easy to use and supports both Windows as well as Mac operating systems.
* Free version of the product only previews recoverable data.
Steps to Utilize MS Excel Repair Tool:
Conclusion:
Hope this article helps you to repair the runtime error 1004 in Excel and recovers Excel file data. In this article, we have provided a manual as well as automatic solution to get rid of Excel run-time error 1004. You can make use of any solution according to your desire.
Good Luck!!!
Priyanka is an entrepreneur & content marketing expert. She writes tech blogs and has expertise in MS Office, Excel, and other tech subjects. Her distinctive art of presenting tech information in the easy-to-understand language is very impressive. When not writing, she loves unplanned travels.
Contents
- What Is the Runtime Error 1004 In Excel?
- Why Am I Getting the Excel Runtime Error 1004?
- How to Fix the Runtime Error 1004 in Excel on Windows 10
- The following solutions have been proven to work:
- Fix 1: Run an Antimalware Scan
- Fix 2: Allow Access to the VBA Project Object Model
- Fix 3: Create a New Excel Template
- Fix 4: Uninstall Microsoft Works
- Fix 5: Remove GWXL97.XLA
- Conclusion
Are you searching for how to fix ‘Cannot run the macro’ in Excel? Then you’ve come to the right place. The message is one of many that may appear as a result of Runtime Error 1004. Other variations of the Excel Error 1004 include:
- Application-defined or object-defined error: Runtime Error 1004
- Method ‘Ranger’ of Object Worksheet Failed
- Copy method of worksheet class failed
- Programmatic access to Visual Basic Project is not trusted
- Excel macro “Run-time error 1004″
- Method open of object workbooks failed: Runtime Error 1004
- Select method of Range class failed: Excel VBA Runtime Error 1004
- Application-defined or object-defined error: Save As VBA Run Time Error 1004
- Method range of object _global failed visual basic: Runtime Error 1004
What Is the Runtime Error 1004 In Excel?
Microsoft Excel is a useful and highly demanded spreadsheet that makes data computation easy. It is used by both individuals and businesses all over the world and comes in XLS and XLSX format.
However, while working on an Excel file or trying to generate a Macro, many users have been aggravated by the Runtime Error 1004. It prevents you from making any changes in your Excel workbook, makes you unable to use certain resource libraries, and freezes or crashes the program or even your system. It causes annoying performance problems while working with Visual Basic applications.
The Runtime Error 1004 can occur on any version of Excel: from Excel 2003 to Excel 2019. It mostly appears when you try running Microsoft Visual Basic for Applications Macro. The problem is due to a security procedure that is meant to lock Microsoft VBA from Excel. The Runtime Error 1004 likely won’t occur if you grant security access. The error could also be due to program corruption as a result of malware infection.
Why Am I Getting the Excel Runtime Error 1004?
The Runtime Error 1004 can appear as a result of:
- Corrupt MS Excel desktop shortcut.
- Copying and pasting filtered data into an MS Office Excel workbook.
- Program conflict while opening the VBA Excel file.
- Programmatically setting a range of values with a collection of large string.
- Application or object-defined error.
Whatever the reason may be, the issue is easy to get rid of. Keep reading to learn how to fix the Runtime Error 1004 when you make changes in Excel.
How to Fix the Runtime Error 1004 in Excel on Windows 10
The following solutions have been proven to work:
- Run an antimalware scan
- Allow Access to the VBA Project Object Model
- Create a new Excel template
- Uninstall Microsoft Works
- Remove GWXL97.XLA
By the time you have tried one or a few of the above fixes, the error will be resolved. We will now provide you with detailed steps to carry out the solutions.
Fix 1: Run an Antimalware Scan
This is the first fix you should try once you get the Runtime Error 1004. If your system is infected with viruses and other types of malware, you will run into unpleasant and unexpected issues. Your system and application will malfunction. Moreover, important files and documents get corrupted.
Run a full system scan with a strong antivirus program. We recommend you use Auslogics Anti-Malware. The tool has precision tools to detect and eliminate even the most elusive malicious elements that your existing antivirus program may miss. Auslogics is a Microsoft partner. They are a certified Microsoft Silver Application developer. Auslogics products have been tested and trusted by experts and millions of users worldwide.
Fix 2: Allow Access to the VBA Project Object Model
The procedure for this solution is easy. Follow the steps below:
- Launch Excel and click on the File tab.
- Click on Options.
- Click on Trust Center. It is the last option in the left pane.
- Click the Trust Center Settings button in the right pane.
- In the new page that opens, locate Macro Settings in the left pane and click on it.
- Mark the checkbox for ‘Trust access to the VBA project object model’ under the Developer Macro Settings section in the right pane.
- Click the OK button.
Fix 3: Create a New Excel Template
Rather than copy or duplicate your existing worksheet, you can put your new Excel Worksheet file within a template. This will help fix the Runtime Error 1004. Here’s how to get it done:
- Launch Excel.
- Press the Ctrl + N combination on your keyboard to open a new workbook. Make sure to leave only one sheet on the workbook. Delete the rest.
- Modify the workbook to suit your needs.
- Save the workbook by pressing Ctrl + S on your keyboard. Or if you use Excel 2003, click on the File tab and click Save as. For Excel 2007 and newer versions, click the Microsoft Office icon in the top-left corner of your screen and then click on Save as.
- Choose a location to save the file on your computer and enter a name for the file.
- Click the drop-down arrow beside ‘Save as type’ and select Excel Template (.xlt) if you are using Excel 2003. If you are using Excel 2007 and later versions, select Excel Template (.xltx) instead.
- After saving the template, use the following code to insert it:
Add Type:=pathfilename
Make sure to replace “pathfilename” with the actual path and file name of the template.
Fix 4: Uninstall Microsoft Works
Here’s the procedure to follow:
- Right-click on the Start button to open the Power User menu. Select Task Manager from the list. Alternatively, press the Ctrl + Alt + Del combination on your keyboard and then click on Task Manager.
- Once in Task Manager, click on each of the running apps and click the End Task button.
- Close the Task Manager window.
- Open the Run utility by pressing the Windows + R keyboard combination. Type “appwiz.cpl” (no quotes) into the text field and click the OK button or press Enter on your keyboard.
- Locate Microsoft Works in the list of apps and right-click on it. Then, click on Uninstall from the context menu. Confirm the action if prompted.
Fix 5: Remove GWXL97.XLA
Here’s how to delete the GWXL97.XLA file:
- Press the Windows + E combination on your keyboard to open File Explorer.
- Navigate this path: C: Users > User > Name > AppData > Local> MicrosoftExcel.
- Open the XLStart folder.
- Locate and delete the GWXL97.aXLA file.
Conclusion
We hope the solutions provided above have helped you to successfully fix the Runtime Error 1004 in Microsoft Excel and recover the data on your file. There are many issues that can lead to the runtime error. However, by the time you get to the end of this guide, you will be just fine.
Don’t hesitate to leave your questions or comments in the section below. We love hearing from you.
Do you like this post? 🙂
Please rate and share it and subscribe to our newsletter!
5 votes,
average: 5.00 out of
5
Loading…
Microsoft Excel is one of the most popular spreadsheets used across the globe for both individual and business purposes. It is the one-stop destination for storing, organizing, and manipulating data in an organized way. MS Excel comes mainly in two extensions i.e. XLS and XLSX format. However, apart from its incredible popularity, runtime errors are a common nuisance for many Windows users – and one of the most common ones is the Runtime Error 1004.
In this guide, we are going to discuss this common Runtime error 1004 and some of the best fixes to resolve it effortlessly.
What is Runtime Error 1004 in Excel?
Runtime error 1004 is an error code relating to Microsoft Visual Basic that has been known to disturb Microsoft Excel users. This error is faced by any versions of MS Excel such as Excel 2007, 2010, 2013, 2016, 2019 as well. No version of Microsoft Excel is safe from the menace of Runtime Error 1004. In some cases, you may see the runtime error 1004 in Excel after opening a worksheet. Such types of runtime errors usually occur due to a problematic add-in.
This error is mainly encountered by users while they are working on an excel file or trying to generate a Macro in the excel document. It can cause serious trouble while working with Visual Basic Applications and can completely crash a program, or even the entire system; sometimes it may freeze the system prohibiting the users to do anything on their system.
Types of error message
The error messages that are most associated with this runtime error are as follows:
- VB: run-time error ‘1004’: Application-defined or object-defined error
- Excel VBA Runtime error 1004 “Select method of Range class failed”
- runtime error 1004 method range of object _global failed visual basic
- Excel macro “Run-time error ‘1004?
- Runtime error 1004 method open of object workbooks failed
- Run-Time error ‘1004’: Method ‘Ranger’ of Object’ Worksheet’ Failed
- “Method in Key up Object Program APPLICATION Failed.”
- Run-time error ‘1004’: Activate method of Worksheet class failed
If you encounter any of these above errors, then you can fix the error using our guide.
What are the causes?
The Error 1004 is a general code related to MS Excel but is not specific to one exact cause. Hence, in this case, the exact reason why this error might pop up will vary from case to case and circumstance to circumstance. From configuration issues to software problems, below we listed a synopsis of common reasons for runtime error 1004 in excel:
- MS Excel Desktop Icon might be corrupted
- VBA Excel File is clashing with other application
- Due to application or object specified error
- Due to missing dependent file
- Due to Virus, Trojan or malware
- Due to Invalid Registry Keys and so on.
These were a few of the most common reasons behind getting the runtime error 1004 in MS Excel; now let us understand the different fixes.
Here we have detailed both manual and automatic solutions to fix the Runtime Error 1004. You can follow any one of the next methods to resolve the issue.
- Create a new Excel template
- Launch Excel in Safe Mode
- Run a Virus Scan
- For VB: run-time error ‘1004’, resize legend entries
Let’s look at each of these methods in detail.
1] Create a new Excel template
In some cases, fixing this issue can be as simple as inserting a new worksheet from a template instead of creating a copy of an existing worksheet. Here is what you need to do:
1] Open MS Excel on your system
2] Press ‘CTRL + N’ to create a new Microsoft Excel worksheet or simply select a ‘Blank workbook’ from the first screen.
3] Once done delete all the sheets on the workbook except one.
4] Now, format the workbook, which has been left. Also, note, this workbook can be modified to suit your individual need.
5] In the end, go to ‘File > Save As’ to save the new worksheet with the Excel Template (.xltx or .xlt) file format.
6] Once you have successfully created the template, you can insert it programmatically by using the following line of code:
Sheets.Add Type:=pathfilename
Please note – Do not forget to replace the new filename with the actual name of the document.
2] Launch Excel in Safe Mode
If Excel is showing you the runtime error 1004 after opening an Excel file, there might be a problematic add-in causing the issue. The affected users received the error message given below:
Run-time error ‘1004’: Activate method of Worksheet class failed
To check if the problem is caused by an add-in or not, launch Excel in Safe Mode. If Excel opens successfully in the Safe Mode, the problem was occurring due to an add-in. Now, you have to identify the problematic add-in. To do that, follow the steps provided below:
- In Safe Mode, go to “File > Options > Add-Ins.”
- Select COM Add-ins in the drop-down on the right side and click Go.
- In Safe Mode, some add-ins are disabled. You have to enable the disabled add-ins one by one. Enable one of the disabled add-ins and restart Excel in normal mode. See if the error occurs.
If the error occurs, repeat the above steps again. After you find the problematic add-in, consider removing it from Excel.
3] Run a Virus Scan
It is very important to scan your computer system for malware and viruses as these can corrupt files and important documents and show the runtime error 1004 in MS Excel. Sometimes using a good antivirus program helps a lot.
Related: Run-time error 1004, Cannot run the Macro in Excel.
4] For VB: run-time error ‘1004’, resize legend entries
If you come across a Runtime Error 1004 when running a Microsoft Visual Basic for Applications (VBA) macro, then you can use this method to work-around.
Generally, you get this error when you try to run a VBA macro that uses the LegendEntries method to make changes to legend entries in a Microsoft Excel chart. That time, you may receive the following error message:
Run-time error ‘1004’: Application or object-defined error
This error occurs when the Excel chart contains more legend entries than there is space available to display the legend entries on the Excel chart. When this behavior occurs, Microsoft Excel may truncate the legend entries.
To work around this behavior, create a macro that reduces the font size of the Excel chart legend text before your VBA macro makes changes to the chart legend and then restore the font size of the chart legend so that it is similar to the following macro example.
Sub ResizeLegendEntries() With Worksheets("Sheet1").ChartObjects(1).Activate ' Store the current font size fntSZ = ActiveChart.Legend.Font.Size 'Temporarily change the font size. ActiveChart.Legend.Font.Size = 2 'Place your LegendEntries macro code here to make 'the changes that you want to the chart legend. ' Restore the font size. ActiveChart.Legend.Font.Size = fntSZ End With End Sub
We hope this article helps you fix the runtime error 1004 in Microsoft Excel. This guide gives you manual as well as automatic solution to get rid of this error; you can make use of any solution based on your need.
How do I fix a runtime error?
Runtime errors occur at the time of running a program. The runtime errors usually freeze or crash the affected program or software. To fix a runtime error, you can use general fixes, like installing the latest Microsoft Visual C++ Redistributables, running the SFC and DISM scans, troubleshooting in a Clean Boot state, etc.
Read next: Arrows keys not working in Microsoft Excel.
VBA Runtime Error 1004 occurs while you are executing a macro in Excel. It’s an error that can occur due to several reasons. In the below example, as you can see, when I run the code, it shows the run-time error ‘1004’. In simple words, you can also say it occurs when you can’t perform an activity with the object or the application.
In this tutorial, we will understand several other reasons for this runtime 1004 error.
Error1: VBA Run Time Error 1004: That Name is already taken. Try a different One:
As I shared above, when you try to add a sheet with the name that is already there in the workbook using a VBA code, VBA shows you a run-time error with the 1004 code.
Even when you try to rename a worksheet, you’ll get the same error from VBA.
In the above code, I tried to rename the sheet “Sheet2” with the name “Sheet1”, but as you can see, I already have the “Sheet1” in the workbook; VBA showed me the error code 1004.
To deal with this problem is to check if a sheet already exists in the workbook or not.
Error2: VBA Run Time Error 1004: Method “Range” of object’ _ Global’ failed:
As you know, you can create a named range in Excel, but when you try to refer to that named range using a VBA code, and you misspelled its name, you are likely to get the run-time error 1004 Method “Range” of object’ _ Global’ failed.
In the following example, I have a named range with the name “myRange”, but while writing the macro, I have misspelled it as “myRang” even though it’s a typing mistake; VBA is not that smart to identify this mistake, and refer to the correct named range.
There is no named range with the name that I have mentioned, and that is why it showed me the run-time error 1004.
Error3: VBA Run Time Error 1004: Select Method of Range class failed:
When you use a VBA code to select a range that is not in the active worksheet, VBA will show you the run-time error 1004. Because, if you want to select a cell or range of cells for a particular worksheet needs to be active at that point.
You cannot select a cell from sheet1 if sheet2 is active right now.
As you can see in the following example, I have made the same mistake where I’m referring to cell A1 from sheet one, but sheet2 is active.
The best way to deal with this error is to activate the sheet first and then write a line of code that selects a cell or the range from that sheet. You can also check if a sheet is active or not and then select the cell from that sheet, and if somehow that sheet is not active, you can show a message to the user to activate that sheet first.
Error4: VBA Runtime Error 1004 Activate method range class failed:
Just like the above reason, when you try to activate a cell or range of cells from a specific worksheet that is not active at the moment, we will show you runtime error 1004 (Activate method range class failed:).
In the about example when I tried to activate cell A1 in the sheet1 it gave me runtime error 1004, is the active sheet was the sheet2.
To deal with this error again you need to verify that the worksheet that you are referring to is active or not. Or you can also verify if that sheet is there in the workbook or not.
Error5: VBA Runtime Error 1004 method Sorry We couldn’t Find:
If you’re trying to open an Excel file using a path, but that workbook is not there, maybe it has been moved, deleted, or renamed. In that case, VBA will again show you a run-time error of 1004.
That’s what happened in the following example where I tried to open the file with the path from my desktop, but that file is not there, and it has shown me an error.
To deal with the situation, you can use a VBA code to verify if the file that you are referring to is there in the folder or not.
Error6: VBA Runtime Error 1004 method open of object workbooks failed:
This error is also related to the workbook. So when you try to open a workbook with the name for which a book already exists and is open at the moment, VBA will show you the run-time error 1004 (method open of object workbooks failed).
The same thing happened in the above example, where I tried to open a workbook that is already open, and VBA showed me a run time error (1004).
How to Correct VBA’s Runtime (Error 1004)
Error 1004 is a run-time error that occurs while executing a VBA code. And all the errors that we have discussed above are due to human errors while writing the code, following the points you can use to avoid the run-time error 1004.
- Do a step-by-step code execution to see on which line the error occurs.
- Make sure to verify all the names of the workbooks that you are referring to.
- You can also use a VBA code to verify if a workbook is already opened or not.
- And use the activate method to activate a worksheet before you refer to a cell or range from it.
More on VBA Errors
Subscript Out of Range (Error 9) | Type Mismatch (Error 13) | Object Required (Error 424) | Out of Memory (Error 7) | Object Doesn’t Support this Property or Method (Error 438) | Invalid Procedure Call Or Argument (Error 5) | Overflow (Error 6) | Automation error (Error 440) | VBA Error 400
Four ways to fix runtime error 1004 in Excel:
Workable Solutions | Step-by-step Troubleshooting |
---|---|
Fix 1. Delete the GWXL97.XLA Files | Fix the Excel error 1004 is to find and delete the error file. Go to C:Program FilesMS OfficeOfficeXLSTART…Full steps |
Fix 2. Check the Trust Access to the VBA Project Object Model | Enable a VBA project trust option in Excel Trust Center to fix Excel error 1004. Open a blank Excel file…Full steps |
Fix 3. Create Another Excel Template | Start a new Excel workbook and make sure there is only one worksheet in it. Format the workbook first…Full steps |
Fix 4. Repair Corrupted Excel File | Repair corrupted Excel files with a file recovery tool. EaseUS file repair tool fixes severely corrupted XLS and XLSX files and retrieves everything from Excel…Full steps |
Microsoft Visual Basic for Applications (VBA) is developed to help users write programs for the Windows operating system. It runs as an internal programming language in Microsoft Office, such as Word, Excel, and PowerPoint.
Some users have reported that when running VBA in an Excel chart or trying to generate a Macro in Excel documents, an error message popped up saying: Runtime error 1004. And then they find themselves cannot access the Excel files. If you have the same encounter as these users, this post is the right place for you. You can find both the reasons and the corresponding solutions of this error code on this page.
Runtime Error Details
The error message contains more information than the error code 1004. Generally, follow the error code, you can see a brief description. The most repeated error messages are listed below:
- Runtime error 1004: Application or object-defined error.
- Runtime error 1004: Method Ranger of Object Worksheet failed.
- Runtime error 1004: Copy Method of Worksheet Class failed.
The Reason Why You See Runtime Error 1004 in Excel
If you want to know how to fix runtime error 1004 in Excel properly, you need to understand what leads to this issue. The following are the most prominent reasons.
- Macro Name Error
The Macro you are running is copying the original worksheet to a workbook with a defined name that you did not save and close before running the Macro.
- File Conflict
When opening the VBA Excel file, it gets conflicted with other programs.
- Too Many Legend Entries
The Excel chart contains more legend entries than space available to display the legend entries on the chart.
- Excel File Corruption
Your .xls files got corrupted, infected, or damaged.
Although many reasons would cause this Excel error 1004 problem, luckily, some valid methods can help users re-access the files. Let’s check them one by one.
Fix 1. Delete the GWXL97.XLA Files to Fix Runtime Error 1004 in Excel
The easiest method to fix the Excel error 1004 is to find and delete the error file.
Step 1. Go to C:Program FilesMS OfficeOfficeXLSTART.
Step 2. Find GWXL97.XLA file and delete it.
Step 3. Reopen your Excel file and check if the problem is solved.
Fix 2. Check the Trust Access to the VBA Project Object Model
Another solution you can try is to enable a VBA project trust option in Excel Trust Center. Follow the detailed steps and have a try.
Step 1. Open a blank Excel file and click «Files» on the upper left.
Step 2. Click Option and go to Trust Center.
Step 3. Find and enter the Trust Center Settings.
Step 4. Under Macro Settings, tick the option of «Trust access to the VBA project object model.»
Now you can check your Excel file.
Fix 3. Create Another Excel Template to Fix Runtime Error 1004 in Excel
This method could be a little bit complicated, but it’s useful and worth trying.
Step 1. Please start a new Excel workbook and make sure there is only one worksheet in it.
Step 2. Format the workbook first and then put the data you need onto it.
Step 3. Tap File > Save As, first enter the file name, and click the unfold arrow in Save as Type column.
Excel 2003: Choose Excel 97-2003 Template.
Excel 2007 or Later: Choose Excel Template.
Step 4. Click «Save» to confirm.
Now you can insert it programmatically by using the following code: Add Type:=pathfilename. The file name is the one you set when you create the new Excel template.
Fix 4. Repair Corrupted Excel Files Due to Error 1004
If all the above solutions can’t help you out, then there is one possibility that the Excel file you want to open is damaged. To fix a damaged Excel file, you can rely on file repair software. EaseUS Data Recovery Wizard is a great choice.
With this tool, click the «Repair» button and wait for it to fix all the corrupted documents for you.
- Repair various corrupted files, including repairing Word, Excel, and PDF document
- Fix unreadable contents in Word efficiently
- Repair corrupted PDF files, extract the text, comments, labels, graphics, etc.
- Compatible with Microsoft Office 2019, 2016, 2013, 2010, & previous versions.
Download the software and follow the detailed steps below to fix corrupted Excel files.
Step 1. Launch EaseUS Data Recovery Wizard, and then scan disk with corrupted documents. This software enables you to fix damaged Word, Excel, PPT, and PDF files in same steps.
Step 2. EaseUS data recovery and repair tool will scan for all lost and corrupted files. You can find the target files by file type or type the file name in the search box.
Step 3. EaseUS Data Recovery Wizard can repair your damaged documents automatically. After file preview, you can click «Recover» to save the repaired Word, Excel, and PDF document files to a safe location.
The Bottom Line
After reading, you must have a thorough understanding of how to fix Runtime error 1004. If you can make sure that the Excel file you want to open is valid, then the first three methods would help you out.
Once you got a damaged Excel file, a professional file recovery tool is a wiser choice. EaseUS file repair software is highly recommended by many users & IT professionals to help you repair Word, Excel, PowerPoint, and PDF files.
Майкрософт Эксель — одна из самых популярных электронных таблиц, используемых во всем мире как для личных, так и для деловых целей. Это универсальное место для хранения, организации и обработки данных организованным способом. MS Excel поставляется в основном с двумя расширениями, то есть в формате XLS и XLSX. Однако, помимо невероятной популярности, ошибки во время выполнения — обычная неприятность для очень многих пользователей Windows, и одной из самых распространенных является ошибка. Ошибка выполнения 1004.
В этом руководстве мы собираемся обсудить эту распространенную ошибку времени выполнения 1004 и некоторые из лучших исправлений для ее легкого решения.
Что такое ошибка времени выполнения 1004 в Excel?
Ошибка выполнения 1004 — это код ошибки, относящийся к Microsoft Visual Basic, который, как известно, беспокоит пользователей Microsoft Excel. С этой ошибкой сталкиваются любые версии MS Excel, такие как Excel 2007, 2010, 2013, 2016, 2019. Ни одна версия Microsoft Excel не застрахована от угрозы Runtime Error 1004.
С этой ошибкой в основном сталкиваются пользователи, когда они работают с файлом Excel или пытаются создать макрос в документе Excel. Это может вызвать серьезные проблемы при работе с приложениями Visual Basic и привести к полному сбою программы или даже всей системы; иногда это может привести к зависанию системы, запрещая пользователям что-либо делать в своей системе.
Типы сообщений об ошибках
Сообщения об ошибках, которые больше всего связаны с этой ошибкой времени выполнения, следующие:
- VB: ошибка времени выполнения ‘1004’: ошибка приложения или объекта
- Ошибка выполнения Excel VBA 1004 «Ошибка выбора метода класса Range»
- ошибка времени выполнения 1004 диапазон метода объекта _global не удалось Visual Basic
- Макрос Excel «Ошибка выполнения» 1004?
- Ошибка выполнения 1004 не удалось открыть метод объектных книг
- Ошибка времени выполнения «1004»: сбой метода «Рейнджер» объекта «Рабочий лист»
- «Сбой метода в ПРИЛОЖЕНИИ ПРИЛОЖЕНИЯ ОБЪЕКТНОЙ программы».
Если вы столкнулись с какой-либо из этих ошибок, вы можете исправить ее с помощью нашего руководства.
Каковы причины?
Ошибка 1004 — это общий код, связанный с MS Excel, но не связанный с одной точной причиной. Следовательно, в этом случае точная причина, по которой может появиться эта ошибка, будет варьироваться от случая к случаю и от обстоятельств к обстоятельствам. От проблем с конфигурацией до проблем с программным обеспечением, ниже мы перечислили краткий обзор распространенных причин ошибки времени выполнения 1004 в Excel:
- Значок рабочего стола MS Excel может быть поврежден
- Файл VBA Excel конфликтует с другим приложением
- Из-за ошибки, указанной в приложении или объекте
- Из-за отсутствия зависимого файла
- Из-за вируса, трояна или вредоносного ПО
- Из-за неверных ключей реестра и так далее.
Это были некоторые из наиболее частых причин получения ошибки времени выполнения 1004 в MS Excel; Теперь давайте разберемся с различными исправлениями.
Здесь мы подробно описали как ручные, так и автоматические решения для исправления ошибки выполнения 1004. Вы можете использовать любой из следующих методов, чтобы решить проблему.
- Создать новый шаблон Excel
- Запустите сканирование на вирусы
- Для VB: ошибка времени выполнения ‘1004’, измените размер записей легенды
Давайте подробно рассмотрим каждый из этих методов.
1]Создайте новый шаблон Excel
В некоторых случаях для устранения этой проблемы достаточно просто вставить новый лист из шаблона вместо создания копии существующего листа. Вот что вам нужно сделать:
1]Откройте MS Excel в вашей системе
2]Нажмите ‘CTRL + N‘для создания нового листа Microsoft Excel или просто выберите’Пустая книга‘с первого экрана.
3]После этого удалите все листы в книге, кроме одного.
4]Теперь отформатируйте оставшуюся книгу. Также обратите внимание, что эту книгу можно изменить в соответствии с вашими индивидуальными потребностями.
5]В конце перейдите к ‘Файл> Сохранить как‘, чтобы сохранить новый рабочий лист в формате файла шаблона Excel (.xltx или .xlt).
6]После успешного создания шаблона вы можете вставить его программно, используя следующую строку кода:
Таблицы.Добавить Тип: = путь имя файла
Пожалуйста, обрати внимание — Не забудьте заменить новое имя файла на настоящее имя документа.
2]Запустите сканирование на вирусы
Очень важно сканировать компьютерную систему на наличие вредоносных программ и вирусов, поскольку они могут повредить файлы и важные документы и показать ошибку времени выполнения 1004 в MS Excel. Иногда очень помогает хорошая антивирусная программа.
3]Для VB: ошибка времени выполнения «1004», измените размер записей легенды.
Если вы столкнулись с ошибкой времени выполнения 1004 при запуске макроса Microsoft Visual Basic для приложений (VBA), вы можете использовать этот метод для временного решения.
Обычно эта ошибка возникает при попытке запустить макрос VBA, который использует метод LegendEntries для внесения изменений в записи легенды на диаграмме Microsoft Excel. На этот раз вы можете получить следующее сообщение об ошибке:
Ошибка времени выполнения ‘1004’: ошибка приложения или объекта
Эта ошибка возникает, когда диаграмма Excel содержит больше записей легенды, чем имеется место для отображения записей легенды на диаграмме Excel. В этом случае Microsoft Excel может усекать записи легенды.
Чтобы обойти это поведение, создайте макрос, который уменьшает размер шрифта текста легенды диаграммы Excel до того, как макрос VBA внесет изменения в легенду диаграммы, а затем восстановите размер шрифта легенды диаграммы, чтобы он был похож на следующий пример макроса. .
Sub ResizeLegendEntries() With Worksheets("Sheet1").ChartObjects(1).Activate ' Store the current font size fntSZ = ActiveChart.Legend.Font.Size 'Temporarily change the font size. ActiveChart.Legend.Font.Size = 2 'Place your LegendEntries macro code here to make 'the changes that you want to the chart legend. ' Restore the font size. ActiveChart.Legend.Font.Size = fntSZ End With End Sub
Мы надеемся, что эта статья поможет вам исправить ошибку времени выполнения 1004 в Microsoft Excel. Это руководство дает вам как ручное, так и автоматическое решение, чтобы избавиться от этой ошибки; вы можете использовать любое решение в зависимости от ваших потребностей.
Читать дальше: Клавиши со стрелками не работают в Microsoft Excel.
Excel VBA Error 1004
VBA 1004 Error is an error we encounter while we execute a code in VBA it is also known as VBA Runtime error. While we work in VBA or in any other programming language or even in our daily work we encounter different kinds of errors. Sometimes even we miss a single character in the code which causes the whole code not to work or maybe the entire code is wrong.
Errors are definitely a part of the code we write. It may be unintentional but they exist. No matter how pro we are in coding, runtime error can occur anywhere. As explained above VBA 1004 Error is an error which occurs during the runtime of the code in excel. It is also called an application defined or object defined error.
There are different types of reasons we get VBA Runtime Error 1004 in excel, let us learn a few of them.
- VBA Runtime Error 1004: Method ‘Range’ of object ‘_ Global’ failed:
This error occurs when the range value we refer to VBA is incorrect. It is also called as Method “Range” of object’ _ Global’ failed.
- VBA Run Time Error 1004: That Name is already taken. Try a different One:
We give the same name to a worksheet which is already taken by another worksheet.
- VBA Runtime Error 1004: Unable to get the select property of Range class:
This is an error when we select a range in another worksheet without activating the worksheet we are referring to.
- VBA Runtime Error 1004: Method ‘Open’ of object ‘Workbooks’ failed:
This error occurs when we try to open a workbook which is already open or the file is used by another program already.
- VBA Runtime Error 1004: Sorry We Couldn’t Find:
We get this error when we try to open a worksheet which doesn’t exist.
As we have learned there can be various reasons we get a runtime error. Runtime error can occur at any line of code. We need to learn how to learn to handle these errors and it is called VBA Error Handling.
Example of VBA Runtime Error 1004 in Excel
Now as I have described different types of error which can occur during runtime of any VBA code now let us learn them how they appear with examples.
You can download this VBA 1004 Error Excel Template here – VBA 1004 Error Excel Template
VBA Runtime Error 1004 – Example #1
As explained about this error, this error occurs when we refer to an incorrect named range value in VBA. This can happen if we make a spelling mistake of the named range of to refer a range that doesn’t even exist. To demonstrate this let us make a named range first. I have the following data here.
- Let us name this table header as DATA.
- Go to the Developer tab click on Visual Basic to Open VB Editor.
- Declare the sub-function to start writing the code.
Code:
Sub Sample() End Sub
- Call the header we named by the following code written below.
Code:
Sub Sample() Range("Data").Select End Sub
- When we run the code we can see in the excel that it has been selected as we have called the header correctly.
- Now we misspell the spelling for the header name.
Code:
Sub Sample() Range("Dataa").Select End Sub
- Run the code again to see the result.
We get excel VBA Runtime Error 1004 because we have misspelled the range name.
VBA Runtime Error 1004 – Example #2
We get this error when we try to rename a worksheet with a name which is already taken. For example, I have renamed sheet 1 as “Anand” and I will try to rename sheet 2 as same then see the result.
- Go to the Developer tab click on Visual Basic to Open VB Editor.
- Declare a sub-function to start writing the code.
Code:
Sub Sample1() End Sub
- Try to rename sheet 2 as Anand by the following code below,
Code:
Sub Sample1() Worksheets("Sheet2").Name = "Anand" End Sub
- Run the above code and see the result.
When I try to rename a sheet with the name which is already taken I get an Error.
VBA Runtime Error 1004 – Example #3
I will try to add the value from sheet 2 to a variable in sheet 3. But I will not activate the sheet 2 and see what happens.
- Go to the Developer tab click on Visual Basic to Open VB Editor.
- Declare a sub-function to start writing the code.
Code:
Sub Sample2() End Sub
- Declare two variables A and B as an integer.
Code:
Sub Sample2() Dim A As Integer Dim B As Integer End Sub
- In Variable B store the value of A in addition to cell A1 of sheet 2.
Code:
Sub Sample2() Dim A As Integer Dim B As Integer B = A + Worksheets("Sheet2").Range("A1").Select End Sub
- Let us suppose the code works and use msgbox function to display the value of B.
Code:
Sub Sample2() Dim A As Integer Dim B As Integer B = A + Worksheets("Sheet2").Range("A1").Select MsgBox B End Sub
- Run the code to see the result obtained.
We get this Error because we have not activated sheet 2 but we are trying to use a value of sheet 2.
VBA Runtime Error 1004 – Example #4
We encounter this runtime error when we have already the same name of workbook open but we try to open it again.
For this example, I have already renamed my workbook as VBA 1004 Error.xlsm and I will try to open it again which is already open and see if I get VBA 1004 Error.
- Go to the Developer tab click on Visual Basic to Open VB Editor.
- Declare a sub-function to start writing the code.
Code:
Sub Sample3() End Sub
- Declare a variable as the workbook.
Code:
Sub Sample3() Dim A As Workbook End Sub
Try to open the workbook we have currently already open with the following code.
Code:
Sub Sample3() Dim A As Workbook Set wb = Workbooks.Open("\VBA 1004 Error.xlsm", ReadOnly:=True, CorruptLoad:=xlExtractData) End Sub
Run the above code to see the result.
We get this error because we have already opened the same workbook already.
VBA Runtime Error 1004 – Example #5
We get this error when we try to open a workbook which doesn’t exist. This is somewhat similar to the above error we get as VBA cannot find the workbook.
- Go to the Developer tab click on Visual Basic to Open VB Editor.
- Declare a sub-function to start writing the code.
Code:
Sub Sample4() End Sub
- Try Open any workbook with the following code,
Code:
Sub Sample4() Workbooks.Open Filename:="C:EDUCBA ContentAprilVBA OR Function.xlsm" End Sub
- I have already deleted the sheet from the location.
- Run the code to see the result.
As the sheet doesn’t exist at the given location we get this error.
Things to Remember
- Always check for spelling mistakes.
- Do not rename multiple worksheets with the same name.
- Before calling any other reference to be sure to activate the respective worksheet.
- Before trying to open any other worksheet ensure the path provided is correct.
Recommended Articles
This has been a guide to VBA 1004 Error. Here we discussed Excel VBA Runtime Error 1004 along with practical examples and downloadable excel template. You can also go through our other suggested articles –
- VBA LBound
- VBA While Loop
- VBA IsError
- VBA CLng
VBA 1004 Error is a runtime error in VBA. It is also known as application-defined or object-defined error. Why is that? Because we have a limited number of columns in Excel. When our code gives the command to go out of range, we get a 1004 Error. There are other situations when we get this error when we refer to a range that does not exist in the sheet.
VBA Error 1004 in Excel
VBA 1004 Error is a run time error in VBA and occurs while running the code. Errors are part and parcel of the coding, especially when writing for the first time. Therefore, you may come across many errors in VBA. However, this is common for everybody, and there is no big deal about it.
However, knowing the error of why it is coming makes you avoid those mistakes in the coming future.
In this article, we will discuss one of the important errors in Excel, “VBA 1004 Error”.
Table of contents
- VBA Error 1004 in Excel
- Top 6 Excel VBA 1004 Runtime Errors
- #1 – VBA Run Time Error 1004: That Name is already taken. Try a different One:
- #2 – VBA Run Time Error 1004: Method “Range” of object’ _ Global’ failed:
- # 3 – VBA Run Time Error 1004: Select Method of Range class failed:
- #4 – VBA Runtime Error 1004 method open of object workbooks failed:
- #5 – VBA Runtime Error 1004 method Sorry We couldn’t Find:
- #6 – VBA Runtime Error 1004 Activate method range class failed:
- Recommended Articles
- Top 6 Excel VBA 1004 Runtime Errors
You are free to use this image on your website, templates, etc., Please provide us with an attribution linkArticle Link to be Hyperlinked
For eg:
Source: VBA 1004 Error (wallstreetmojo.com)
Top 6 Excel VBA 1004 Runtime Errors
You can download this VBA 1004 Error Template here – VBA 1004 Error Template
#1 – VBA Run Time Error 1004: That Name is already taken. Try a different One:
This error occurs while renaming the sheet.
If the worksheet’s name already exists. If you try to assign the same name to another sheet, VBA throws a “Run-time error ‘1004.’ ”
Look at the below code.
Code:
Sub Error1004_Example() Worksheets("Sheet2").Name = "Sheet1" End Sub
We are trying to rename sheet 2 as sheet 1. But, we already have a sheet named “Sheet1”.
If we run this code using the F5 key or manually, we will get “Run-time error ‘1004’ “: “That name is already taken. Try a different one.”
So, try renaming the sheet accordingly.
#2 – VBA Run Time Error 1004: Method “Range” of object’ _ Global’ failed:
It usually occurs when we try to access the named range in excelName range in Excel is a name given to a range for the future reference. To name a range, first select the range of data and then insert a table to the range, then put a name to the range from the name box on the left-hand side of the window.read more with a spelling mistake or that does not exist you are referring to.
For this, we have named the range of cells “Headings,” as shown in the below image.
Now, by using the RANGE object, we can access this range.
Code:
Sub Error1004_Example() Range("Headings").Select End Sub
If you run this code by pressing the F5 key, then this code will select the named range.
But, if we mention the named range wrongly, we will get “Run-time error ‘1004.’ “Method “Range” of object’ _ Global” failed.
Code:
Sub Error1004_Example() Range("Headngs").Select End Sub
Run this code manually or use the F5 key and see the result.
# 3 – VBA Run Time Error 1004: Select Method of Range class failed:
It usually occurs when we try to select the cells other than the active sheet without making the sheet select or active.
Look at the below code.
Code:
Sub Error1004_Example() Worksheets("Sheet1").Range("A1:A5").Select End Sub
The above code says to select the cells A1 to A5 in the worksheet “Sheet1”. However, to experiment, my present active sheet is “Sheet2”, not “Sheet1”.
We will run this code using the F5 key or manually to see what happens.
We got “Run-time error ‘1004.’ “Select method of Range class failed” as without activating the sheet; we try to select the cells of that sheet. So first, we need to activate the sheet before we select the cells. Below is the correct code.
#4 – VBA Runtime Error 1004 method open of object workbooks failed:
It usually occurs when you try to open the workbook, which has the same name as the other workbook we have already opened.
Look at the below code.
Code:
Sub Error1004_Example() Dim wb As Workbook Set wb = Workbooks.Open("FileName.xls", ReadOnly:=True, CorruptLoad:=xlExtractData) End Sub
It will throw the below error.
#5 – VBA Runtime Error 1004 method Sorry We couldn’t Find:
This error occurs when you try to open the file which does not exist in the mentioned path. For example, it could move, be renamed, or deleted from the mentioned path. One reason for this is the wrong type of path or file name with the excel extensionExcel extensions represent the file format. It helps the user to save different types of excel files in various formats. For instance, .xlsx is used for simple data, and XLSM is used to store the VBA code.read more.
Now, take a look at the below code.
Code:
Sub Error1004_Example() Workbooks.Open Filename:="E:Excel FilesInfographicsABC.xlsx" End Sub
This code says to open the file “ABC.xlsx” in the mentioned folder path.
We know there is no file in the mentioned folder path. So, we will get the: Run-time error ‘1004’ method when no file exists in the mentioned folder. Sorry, and We couldn’t find it.
#6 – VBA Runtime Error 1004 Activate method range class failed:
This error occurs mainly due to activating the range of cells without activating the worksheet.
Look at the below code.
Code:
Sub Error1004_Example() Worksheets("Sheet1").Range("A1:A5").Activate End Sub
This error is similar to the one we have seen in Run-time error’ 1004′: Select method of Range class failed.
If we run manually or use the F5 key, we will get the below error.
Because without activating the sheet, we cannot activate the cells in it. So first, activate the sheet and then activate the cells of that sheet.
Recommended Articles
This article has been a guide to VBA 1004 Error. Here, we discuss the top 6 types of 1004 run-time errors in VBA and how to fix them, along with examples and downloadable templates. Below are some useful articles related to VBA: –
- VBA LEN Function
- VBA Type Mismatch Error
- VBA Sub Procedures
- VBA Match Function
Runtime errors are common problems faced by Windows users. The error code 1004 is one of them. Microsoft Excel abnormalities or issues with the Microsoft Excel files contribute to this error code. Once it occurs, it will bring different challenges with it, until you resolve the matter. To know more, regarding the error 1004, keep studying this article till the end. From this article, you will also learn effective tricks by which you can get rid of it.
There are a number of variations of the error message, which are as given below.
- Most of the MS Office users get these two variations of the error message.
- Excel macro “Run-time error ‘1004’″
- VB: run-time error ‘1004’: Application-defined or object-defined error
- Other forms of the error message are as follows:runtime error 1004 method range of object _global failed visual basic
- Excel VBA Runtime error 1004 “Select method of Range class failed”Run-Time error ‘1004’: ‘Method Ranger’ of ‘Object Worksheet’ Failed
- Runtime error 1004 method open of object workbooks failedSave As VBA Run-time Error 1004: Application defined or object defined error
There are several factors which are responsible for the error 1004. Some of them are as follows.
- Corrupt or damaged MS Excel application
- VBA Excel file conflict with other programs
- A virus or malware attack
- Invalid Registry Keys
- Application or object defined error
- Absence of important file
No matter what causes the runtime error in MS Excel, after a thorough study of this article you will able to fix this problem efficiently.
Effects of 1004, the Runtime Error in Microsoft Excel
You may already be aware of the effects of the error 1004. In general, many of the users face this error while copying the original worksheet, which is already running in a macro to a workbook along with a name which is pre-defined.
This error can also result in data loss in Excel. Crashing down the program or system while working with Visual Basic Applications is another effect of the error code 1004, the runtime error. As this is a more serious problem, so solving it quickly is a very important task you need to perform. Below, you will get some effective methods to fix this error.
Methods to Solve Runtime Error 1004
Now, here in this section, we are going to discuss the methods with which many users have already utilized to resolve the runtime error code 1004. So, let’s not waste time and try the methods as below.
Run a Virus Scan
Ensuring no presence of viruses in the system will be the best primary task to perform. Because the presence of a virus can damage the system files, which is one of the many other reasons responsible for the error 1004. And the steps which you need to follow to run a virus scan depends on the antivirus tool you are using.
In case, you are a Windows 10 user, then the Windows Defender tool can fix the virus related matters efficiently. The Defender tool is very advanced and can eradicate virus infections in your computer via a complete scan.
Method 1: Uninstall Microsoft Works to Recover MS Excel
After a virus scan if you are still stuck with the error, then uninstall MS Works, which may eradicate the error 1004. And the steps to follow to do it are as below.
- First of all, open the search bar by pressing down the Windows button.
- Then, on the search bar, type control and hit the Enter key. This will brings up the Control Panel window.
- Now, ensure that the View by section is set as Category, and if not, then drop down the menu list for it and select the Category option.
- After that, from the available options, select Programs> Programs and Features to get all the installed programs to list on the screen.
- Now, from this installed programs list, search for Microsoft Works, and right click on it. And then select Uninstall> Uninstall to confirm.
Hopefully, now you can work with the MS Excel application, without getting the error 1004. If however, the error still persists, then continue with the next methods.
Method 2: Delete GWXL97.XLA to Fix Runtime Error
This is another way to solve MS Excel error 1004.
- At first, press both the Windows and the letter E key at a time to get the Windows Explorer open.
- Then, from the available options under the Windows Explorer, double-click on the Program Files folder to open.
- After that, open the Microsoft Office folder and under it you will get a folder named as OfficeXX, open it. In place of XX, you will get the MS Excel version.
- Next, from the available folder options under OfficeXX, open XLSTART.
- Now, here you will get “GWXL97.XLA” under the Name section. Right-click on it and select the Delete option.
- Then, open the Excel file again and check if the issue gets resolved.
Method 3: Save Excel Workbook
Excel is a great project by Microsoft Inc. With the help of the macros facility, you can copy worksheets to save its duplicate into the same workbook where it is actually located. However, if this process is not correctly executed, it can result in error code 1004, the runtime error in Excel. Sometimes, this error code generates as the object-defined error or application-defined error message.
The exact reason behind the error is if the user sets the workbook a name and make a duplicate of it without closing it beforehand.
And after knowing the possible reasons, now, hopefully, your concern will be how to handle this matter. The answer to this is as explained below.
You just need to save the workbook periodically after you have copied it. Also, remember that every time when you want to copy the file, you need to keep saving the file beforehand. The time consumed to save the file depends upon its size. By doing this, you may find that the error gets resolved.
Method 4: Fix Error 1004 by Modifying the Trust Center Settings
According to many users, they get the problem solved by following this method. And the steps to proceed to begin this method is as below.
Before you start this method, ensure that your computer is running with Administrative rights. And then launch the MS Excel application.
Now, take the mouse pointer to the extreme top-left corner of the MS Excel window and that is to the four blocks symboled Office button.
Then, under this Office button window, you will find the Excel button in the bottom right corner, click on it. Next, select the Trust Center option from the left side panel. After that, click on the “Trust Center Settings…” button. This will open up the Trust Center window.
Further, click on the Macro Settings option from the left side panel of this Trust Center window. And then enable the checkbox beside “Trust access to the VBA project object model”, which is located under the Developer Macro Settings section and click on OK. This will bring you two options for solving the problem which are as follows.
- Modifying VBA Macro code for copy and paste purpose of only single rows, which holds the data.
- Modifying VBA Macro code to loop copy, to enhance copying small portions at one time.
Hopefully, after going through this method you will fix the runtime problem 1004.
Method 5: Create New Excel Template
It’s better to create a new worksheet to solve error 1004, rather than copying one. The steps by which you can create a new Excel template is explained below.
At first, launch the Microsoft Excel application. After that, create a new Workbook file. Next, remove Worksheets one by one.
Then make a format to the Workbook of your choice. You can insert charts, data or text in it.
After that, click on the four blocks symboled Office button, and select the “Save As” option. This will pop-up a window, with an option for Save as type and a space for Filename. Set the Save as type as Template, and enter a name for this file and click on the Save button, to complete this method.
Note: If you would like to programmatically insert the template then use the following code:
Sheets.Add Type:=pathfilename
filename = the path of the saved template
Mentioned above are the workarounds to solve 1004, the runtime error. In case there are any queries regarding the error you can leave that in the comment section below.