False error "custom type not defined" error in Microsoft Word VBA
I have a Microsoft Word template with some code and some links that have been working fine for months, but have just started throwing a false "User-defined type" error every time I open or try to compile it.
I know this is a false error because I haven't made any significant changes to the code. In fact, I have reverted the code back to the latest deployed version (which I know works fine) and I still get the error. I have also commented out all the code in the template and I still get the error. I also removed and re-added all references (same error) and removed all references and added them back one by one until the resulting compilation errors are resolved, at which point I am left with a fake "User defined" type not defined. (I'm going to call this a UDTND error from now on, so as not to drive you crazy.) I think the error started showing up after I rebooted my PC. This only happens with this pattern, but I don't see how it could be related to this pattern.
Interestingly, the error is subtly different from the true UDTND error in the following ways:
-
No code is highlighted when an error is displayed.
-
The dialog is named "Microsoft Visual Basic" and contains an error message, but unlike the real UDTND error, it does not contain the text "Compilation error:";
-
This happens when the template is opened, not just when it is compiled (at least I think this is different from a normal error).
I've tried Googling, but I'm just getting bazillion results from novice developers asking why they are getting this error, with answers saying they need to declare a missing type, correct the spelling of the offending variable, or add a link to a missing library. I was banging my head against the screen all day and it helped just like every other thing I tried (i.e. not at all). I have a feeling this is due to a confused link, but I'm fine and have removed and re-added them, which I would expect to resolve this issue.
Any ideas ...?
source to share
I had a user not user defined issue multiple times while compiling Microsoft Visual Basic 6 (MSVB6) code that previously compiled without issue. It seems to be happening after I have had a long coding session without restarting my computer. As you can guess, I am using Microsoft operating systems. I am currently using Windows XP. Restarting the computer usually fixes the problem, as is often the case with Microsoft operating systems.
I've read that fully qualifying declarations can also help, for example "Dim oBar as Foo.Bar" instead of "Dim oBar as Bar". However, I have not tried this approach.
source to share
I had a very similar problem.
My problem appeared (I think) right after I did the search and replace, which I canceled (Ctrl + Z). The problem was not resolved, and only when I compiled the error message "Custom type not defined".
I tried:
1) restarting the computer
2) changing the reference order
3) deleting functions / procedures, modules one by one.
Does not work. My project was written in Excel VBA and here is the solution I found.
DECISION:
I opened a new Excel file and opened the Visual Basic Editor. Then I copied all Forms, Modules and Class Modules one by one to a new file. Then I copied the control objects (3 Commandbuttons) from the old sheet to the new one. The new file was now identical to the old project - only "Unknown custom type was not" and the problem was resolved.
source to share
I had the same problem with Excel 2013.
It started when I did a search and replaced the custom class name. I changed the name of the class after I searched and replaced all references to it, and the false error started right after that.
I went back to an earlier ad, confirmed there was no problem, and then did the same search, replace and rename, and got the same behavior again.
The custom class in which I changed the name had only one consumer and it was also a regular class. I exported, deleted and reloaded the single consumer class and the problem was fixed.
source to share
Check this link for Microsoft error that may be related.
TL; DR:
Package link / add-on / whatever probably needs to be reassigned. From the menu, select Tools → Links .
It also turns out that if you install Microsoft Security Advisory 960715, some of the controls will be killed. There are fixes that may or may not work for you. Good article on this blog:
source to share