Getting "Name conflicts with existing module, project, or object library " when doing Add File to a project

Posted on 2004-11-26
Last Modified: 2010-05-02
I do not see how it would conflict ...

Question by:AlexF777
    LVL 52

    Expert Comment

    by:Carl Tawn
    Are you adding a new file or an existing file ?
    LVL 8

    Accepted Solution

    Well, this happens when two names conflict, obviously.
    It is hard to tell you how to fix this without seeing your
    project. But, one suggestion try a different name.

    Forms have two names.

    Saved file name, and form name. Chances are you have
    two saved names that are different. Say one is saved as
    Calculator.Frm and one is saved as Game.Frm. But both
    have an internal name of Form1. You can not do this, you
    then would have two Form1's and confuse the compiler.

    Simple solution:

    Open both forms individually, go to the Name property,
    and change one to say: Form1, and one to Form2.
    Then, you can reopen your project and add them both.
    Good luck.
    LVL 26

    Expert Comment

    If your reference (class) contains a same name as your form or class or module, then you will get this error

    Author Comment

    it is a .bas file.

    What I have noticed is if my .bas file is a part of some other project - VB complains,
    otherwise - it does not ...
    LVL 8

    Assisted Solution

    This is what I was telling you. It is not a matter of which project it is apart of.
    It is the fact that you have Module1 added in a project. You save this as say
    Winsock.Bas. Then you have another project, say you save a Bas as Skin.Bas.
    But then you think oh! That would be great if this program could connect to
    the internet. Then, you add Winsock.Bas. The program (VB) now errors, it
    can not add Winsock.Bas. Winsock.Bas has a name Module1. The problem
    is you already have Module1(Skin.Bas) Two module1's just can not happen.

    Like I said, what you need to do is open the one you wish to add. Change
    it's name in the property window to something along the lines of what
    the module does, rather than Module1. It is good practice to always change
    your Module names. This way you can easily add Modules to any project
    at any time. Because what are the chances that you have two Winsock.Bas
    modules? The chances are unlikely because, why would you write two
    things that do the same function? So change your names of the Module
    itself, and not the .Bas file. This should allow you to add your modules
    with ease. Good luck.
    LVL 26

    Assisted Solution

    >>What I have noticed is if my .bas file is a part of some other project

    I don't think that is the problem, you may want to change this line

    Attribute VB_Name = "Module1"


    Attribute VB_Name = "somethingelse"

    Open your .bas from notepad, this is the first line appears on the .bas
    LVL 8

    Assisted Solution

    EDDYKT that is exactly what I have said twice now.
    Attribute VB_Name = "NAME" Is the name listed
    under Name in properties window. Once again, you
    need to change this , because two of your items have
    the same name, with different FILE names. And when
    you have two internal names the same like that it
    will give you errors, because it can not handle it.
    LVL 32

    Expert Comment

    Also make sure that the *name* of the module does not conflict with any libraries you have added in Project->References.  e.g. If you add a reference to win32.tlb, you cannot have a module with a name of "win32."

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now