I am seeing an Error 438 in an application which has until this point been run successfully without error for more than 2 years. Debug shows that it fails on a fairly inoccuous line:
With gVarWorkSheet.ListView1
The workbook has not changed since previous successful runs. Is there anything in the installation of Excel or on the Windows XP PC in general that could have changed that would cause this?
Related
Our admins ran some MS Office 2016 updates (Build 11929.20838) and all of a sudden I noticed a few unexpected errors in one of my previously written Excel VBA macros. For example below error is popping up against any variable which I have not defined explicitly. It was not the case before and unless I had mentioned Option Explicit, I had never experienced anything like this.
Compile error:
Can't find project or library
I am also getting the same error against the following 2 statements of my code, whereas it used to run smoothly before the last Microsoft Office 2016 update.
' Against the following two declarations, the compiler is highlighting
' Date in parenthesis and quoting same error "Can't find project or library"
xMonth = VBA.DateTime.Month(Date)
xYear = VBA.DateTime.Year(Date)
' And showing same error as above against defining an Array variable like below
srchString = Array("invoice_number", "invoice_date", "Category_wise_code", "Bill To Customer", "consignees_address_long")
'And even here, it is giving the same error:
[A1].Font.Bold = True
Does anyone have any idea about these errors and how to resolve this issue? All of this quite unexpected. Let me tell you this macro has been in my use for over 4 years and I never ran into issues like these.
You will find something fishy here:
https://www.google.com/search?rlz=1C1CHZL_enGB838GB838&ei=EOInX-ibPMeusAXFw7z4Cg&q=%22ms+office+2016%22+%22july+updates%22+%22VBA%22&oq=%22ms+office+2016%22+%22july+updates%22+%22VBA%22&gs_lcp=CgZwc3ktYWIQAzoECAAQRzoICCEQFhAdEB46BQghEKABUOTJCljq_gtgg4UMaABwAXgAgAHzAogByiiSAQYyLTIuMTSYAQCgAQGqAQdnd3Mtd2l6wAEB&sclient=psy-ab&ved=0ahUKEwjo4_6J5f7qAhVHF6wKHcUhD68Q4dUDCAw&uact=5
Although not all links are opening, but Google window is briefly showing that some people are also facing macro crash situation.
Thanks for your time reading my post.
The hard part of this error is that it does not occur all the time, but I think it is due to the userforms. The program works as it should most of the time, but eventually Error 1 pops out. After Error 1 pops out, when I attempt to double click any other userform module in the VBE, Error 2 would pop out. I believe Error 1 occurs because the program is unable to access the user forms as shown by Error 2. When we attempt to save the Excel file after the error occurs, the excel file would crash. I also noticed that the errors start after a certain amount of time (even when idling and alt+tabbed) after not doing anything for example, 20 minutes, then try to select a userform, it will error (note: I do not have any time activated code for sure). Similar problems were noted in these URLs but no solutions: Similar problem and Similar problem 2. After checking google, this problem have been plaguing people for more than 10 years already. Has no one ever figured out the cause for theirs? Any help would really be much appreciated for other people as well. Update: Errors occur in Excel 2007 (both computers at the office). I've never seen the error occur to my yet at home with my Excel 2016.
The images of the errors and debugging are shown below:
Error 1:
Error 2:
After Error 1 occurs and try to save the file crash:
Debug (all userforms will stop working):
Both errors you are having, "Path/File access error" and "Run Time Error 75" are errors accessing the filepath, and they are likely being caused by the AutoRecover feature of Excel.
When you are leaving your Excel file for 20 minutes or so, the time limit for AutoRecover is reached. AutoRecover will then attempt to save AutoRecover information, in the case of your home computer it will be saving that to the Local drive, and at the office it will be saving to the network.
When an Excel file is open and AutoRecover is turned on, AutoRecover does not save the file until the first change is made to the file, the AutoRecover save time interval passes, and Excel has been idle for some time (the default is 30 seconds). (https://support.microsoft.com/en-us/help/289273/description-of-the-autorecover-functions-in-excel)
What is likely happening is a connection with your network is being interrupted, causing the AutoRecover to fail, which you won't see until the 'ActivateWorkbook' event is triggered (which will show your userform, then crash).
(You can check your time limit for AutoRecover in Options>Save>Save Workbooks)
You might be able to work around the error by:
saving the file to your local drive while you are at the office, or
disabling AutoRecover for the workbook
increasing the amount of time before the AutoRecover is triggered.
This user also found their errors were resolved by removing and repairing corrupt updates: https://www.mrexcel.com/forum/excel-questions/438888-intermittent-run-time-error-75-loading-form.html
Hope this helps!
you can just save the current workbook with this:
ActiveWorkbook.Save
or disabling auto recover with code
Application.Autorecover.Enable = False
I had this error when using the FileCopy(Source, Destination) function. I resolved it by saving a copy of the source file under a different name
This is similar to a question that I've asked yesterday, but I've managed to find a fair bit more information: enough to warrant a new question, I feel.
My office has recently moved to Windows 7 along with Office 2013 - with the except of Access which has stayed as 2003.
Access works absolutely fine except when I try to automate Excel. This is a feature of nearly all my applications.
When I load an old project, the reference is automatically updated to "Microsoft Excel 15.0 Object Library" - it is held as an EXE file in Program Files (x86). Note: it does not say the reference is missing.
When I try to run any code which uses early binding, it fails with the following error message: "Error in loading DLL"
I've since tried late binding by doing the following:
Dim app As Object
Dim wb As Object
Set app = CreateObject("Excel.Application")
app.Visible = True
Set wb = app.Workbooks.Add
This creates the Application, it becomes visible, a Workbook is added, but then I get the following error: "Run-time error '1004':
Application-definted or object-defined error"
If I try to access VBA in the new Workbook I get the following error: "An error occurred initializing the VBA libraries (1004)" The Workbook is loaded in "Compatibility Mode"
The above leads me to believe that the 2 applications may not be compatable, but the following is worth considering:
If I try to use early binding I don't get the Intellisense drop-downs but words like Workbook and Worksheet do auto-capitalise themselves as you would normally expect them to. The code won't compile at all if I don't have the reference set, but it does compile - and throw and error - when it is. I've since tried Word 2013 - who's Object Reference is an OLB file rather than EXE - and I get the full Intellisense features I would except, but it still throws the same error when trying to run.
In a nut shell, does anyone know if I stand any chance of having the 2 work together?
Thanks
I keep getting this error in the dev environment - 'A SafeHandle or CriticalHandle of type 'System.Data.SqlServerCe.HasSafeHandle' failed to properly release the handle with value ...."
It is in a VS 2012 Winforms application and only seems to happen if a particular piece of code is run at some point. The error shows after the form is closed, but I can't understand why. It only happens in the dev environment and seems to be OK in the compiled version, but I don't want to just ignore it.
The error seems to be caused by this line of code, although weirdly at this point in time I have not opened a connection to the SQL ce database and the directory it is searching in does not have the SQL ce database in it. It is mearly reading in txt files that match a pattern
string[] fileNames = Directory.GetFiles(importDirectory, "BucketHistory*.txt")
I'll do some more digging tomorrow, it's late now, and I have no idea what is causing it.
Any pointers ??!
Turns out I was having a bit of brain fade yesterday. Been working too long hours !
For anyone interested, the problem was that I was opening a connection, then copying the file and running a shrink whilst the connection was still open. It had nothing to do with that line of code.
I would have expected the copy to have thrown an exception, but it didn't appear to. Oh, and opening another connection inside the using statement of the first one. Sigh.
I am having a problem with a workbook. It works fine on my machine but when it is run by someone else it is giving a problem with an error message "Compile error can't find project or library"- thing is, it is doing it on a Mid$ string command!
Anyone know what could cause this? Is there a setting they need somewhere? The code was written in Excel 2010 and they are running Excel 2010
This is caused when you have a missing reference. Have a look in Tools > References on the machines that are throwing the error. You should see that certain references are prefixed with MISSING.
These libraries will need to be installed on the other machines in order to use them, alternatively, you could try late binding if they have an earlier version of the reference you are using.
If the above doesn't work, I have experienced this problem when there is a failed installation on the machine. None of the references are missing, but upon opening Excel a (usually unrelated) application gets stuck in a failed install loop. If this is what is happening, you'll need to rectify the failed installation.