Surendra Sharma

Surendra Sharma

Search This Blog

Monday, August 5, 2013

A module is not a valid type

How to fix error “Compile Error: A module is not a valid type” in VB?


This type of error occurred when you are trying to include old version of VB files or VB is unable to recognize the module.

How to fix it?

Copy the code of that particular module, suppose name is “Segmentation.cls”, in notepad file.

Select and Right click file “Segmentation.cls” -> Remove “Segmentation.cls”

Select and Right click Project -> Add -> Class Module -> New -> Select Class Module -> Open

Copy the code from notepad and paste to this new class module file. Save this with same filename “Segmentation.cls”.

Here file content should start with “Option Explicit”.
Content before this line should be commented or removed as below
'Attribute VB_Name = "Segmentation"
'  MultiUse = -1  'True
Option Explicit

Select class module file in Project Explorer and change its Name property to “Segmentation” i.e. same as file name as below

Please leave your comments or share this tip if it’s useful for you.

No comments:

Post a Comment