Ошибка module not found excel

This is a well-described issue, and it exactly matches what I have just experienced (even including the fact that I haven’t been versioning recently).

My file has an xlsb suffix. Resaving with a different suffix did not work for me on the same PC, but I emailed the file to another PC, opened it, saved as xlsm, sent it back to the original machine and it now works fine again. I can even re-save with my preferred xlsb suffix and it still works.

I’ve also run this script to make a backup of my modules:

Sub ExportVbaModules()
     
'Acknowledgements to Andy Pope [ozgrid thread 60787]
     
    Dim objMyProj As VBProject 'if error, go to VBA editor - tools - References - Microsoft Visual Basic-Extensibility5.3
    Dim objVBComp As VBComponent
     
    Set objMyProj = Application.ActiveWorkbook.VBProject
     
    For Each objVBComp In objMyProj.VBComponents
        If objVBComp.Type = vbext_ct_StdModule And objVBComp.Name <> "" Then
            objVBComp.Export "C:UsersMyNameVbaBackups" & objVBComp.Name & ".txt"
        End If
    Next

End Sub

The And objVBComp.Name <> "" stops it from erroring when it encounters a corrupted module but turned out not to be necessary as the ‘fixed’ file contained no corrupted modules.

Since that export routine is so fast (40 modules / 100kb saved in <1s) I will be assigning it to a button on the ribbon with a better naming convention for the files it creates.

Вопрос:

Моя проблема возникает, когда я пытаюсь открыть документ .xls с помощью MS Excel с С#, и этот документ содержит макросы. Я использую библиотеку Microsoft.Office.Interop.Excel (v12). По этой операции я получаю сообщение об ошибке в Microsoft Excel. В окне сообщений из Visual Basic говорится: “Модуль не найден”, а отладчик Visual Studio останавливается также с исключением: “HRESULT 0x800A03EC”.

Как решить эту проблему? Я не хочу использовать макросы, сохраненные с этим файлом, но, по крайней мере, читать значения ячеек…

Лучший ответ:

Excel панически относится к макросам, это параметр внутри Excel, который определяет, что он делает, когда видит файл .xls. В 2007 году используйте параметры Excel, Центр доверия, настройки центра доверия, параметры макроса. Выберите переключатель “Отключить все макросы без уведомлений”.

IIRC, в методе Open есть опция для подавления сообщений.

Ответ №1

Попробуйте OLE DB для Excel. Это будет лучше, чем использование interop.

Permalink

Cannot retrieve contributors at this time

title keywords f1_keywords ms.prod ms.assetid ms.date ms.localizationpriority

Module not found

vblr6.chm1011220

vblr6.chm1011220

office

bd966ba5-606c-dd48-7b2c-f27ca8e5fcee

06/08/2017

medium

Module not found

Modules aren’t loaded from a code reference — they must be part of the project. This error has the following cause and solution:

  • The requested module doesn’t exist in the specified project. For example, the statement MyModule.SomeVar = 5 generates this error when MyModule isn’t visible in the project MyProject. See your host application documentation for information on including the module in the project.

[!includeSupport and feedback]

  1. 05-13-2005, 08:06 AM


    #1

    error «module not found»

    I have problem opening an Excel file. It comes up with «Visual Basic» error
    window, and the error message is «Module not found».

    I’m using Excel 2000 on Windows 98.

    Help provides following info. about the error —
    ————————————————
    Module not found

    Modules aren’t loaded from a code reference — they
    must be part of the project. This error has the
    following cause and solution:

    The requested module doesn’t exist in the specified
    project. For example, the statement MyModule.SomeVar =
    5 generates this error when MyModule isn’t visible in
    the project MyProject.
    See your host application documentation for
    information on including the module in the project.
    ————————————————

    Excel file is provided by a friend who uses Mac, and I think it contains
    some macros.

    Any idea? Thanks in advance.


  2. 05-13-2005, 01:06 PM


    #2

    Re: error «module not found»

    probably some missing references. Go to VB editor. Tools > References.
    Uncheck any ‘missing’ references.

    Mangesh

    «Amit» <Amit@discussions.microsoft.com> wrote in message
    news:BD248BCE-EE72-4218-A603-2DB354749209@microsoft.com…


    > I have problem opening an Excel file. It comes up with «Visual Basic»

    error
    > window, and the error message is «Module not found».
    >
    > I’m using Excel 2000 on Windows 98.
    >
    > Help provides following info. about the error —
    > ————————————————
    > Module not found
    >
    > Modules aren’t loaded from a code reference — they
    > must be part of the project. This error has the
    > following cause and solution:
    >
    > The requested module doesn’t exist in the specified
    > project. For example, the statement MyModule.SomeVar =
    > 5 generates this error when MyModule isn’t visible in
    > the project MyProject.
    > See your host application documentation for
    > information on including the module in the project.
    > ————————————————
    >
    > Excel file is provided by a friend who uses Mac, and I think it contains
    > some macros.
    >
    > Any idea? Thanks in advance.
    >




    • #1

    Hi
    I was trying to work on an excel file created in Excel 2003(at office) in Excel 2002.The following error messages came when I opened the file(at home)

    Visual basic
    Module not found

    Errors were detected but Microsoft Excel has managed to open the file by making the repairs listed below:
    Lost Visual Basic Project
    Lost Active X controls

    Is it due to compatibility problem?Please help
    Regards
    Chari
    _________________
    Using Excel 2002 with Windows XP PRO-SP2. at Home
    Using Excel 2003 with Win XP pro-SP2 in office

    • #2

    Re: VBA Module not found

    Hi Chari

    Welcome to ozgrid

    Try this MSKB results
    Visual Basic for Applications (VBA) functions break in a database with missing references

    Do you have the Complete install on the 2002 version>

    • #3

    Re: VBA Module not found

    Hi
    Thanks for your welcome message and response.My replies
    Try this MSKB results
    Visual Basic for Applications (VBA) functions break in a database with missing references

    Seems to be for Access!Is it applicable to Excel also (since the article pertains to VB)

    Do you have the Complete install on the 2002 version
    Yes

    Since Excel erases the entire VB Project while it opens the file,I am unable to modify any thing in the VBCode.One alternative is to insert the VB code separately in the retrieved file but I am not aware as to how to export/import the entire VB project from one file to a new file.
    Regards
    Chari

    • #4

    Re: VBA Module not found

    I would thik that the problem is in the Workbook_Open Module because that is the first to run. Open the workbook with Macros Disabled then start by checking that code. Post the code up here if it helps.

    By the way the article mentioned refers to Excel 2003 as well

    • #5

    Re: VBA Module not found

    Thanks.Will try that at Home and post the results
    Chari
    P.S.Missed that reference.Will try the same also

    • #6

    Re: VBA Module not found

    Hi
    Tried to open the Excel file by disabling macro but Excel repairs the file while opening and deletes all the modules.Is there any way to stop Excel from repairing the files?
    Regards
    XChari

    • #7

    Re: VBA Module not found

    If macros are disabled then I can’t see how it can be an error in the VBA. Are you opening a new instance of the workbook or the one that you opened previously?

    • #8

    Re: VBA Module not found

    Hi
    Opening the same file.

    After I opt for disabling the macro,the Excel opens the file and says module not found!The original file is Ok when it was tested in Office PC (in a different directory)having Excel 2003 and hence there is no problem in the copied file
    Can you explain how to extract the VBCode from the original file and merge the same in the new file having problem.
    Chari

    • #9

    Re: VBA Module not found

    Chari

    I woulod open it on the PC is DOES open ok on and save another copy. It sounds like the one you have could be corrupt.

    • #10

    Re: VBA Module not found

    Thanks.The copy is OK since it works on the PC in office having Excel 2003.
    Tried 2/3 copies of the same file and got the same problemm at Home PC having Excel 2002 but the same works in office PC (Excel 2003)
    Chari

    • #11

    Re: VBA Module not found

    Can you open other 2003 files on your home PC? On the home one, close Excel completely and then go to Start>Run and type in: excel /regserver Note the space after «excel«.

    • #12

    Re: VBA Module not found

    Hi
    My replies
    Can you open other 2003 files on your home PC?
    Yes
    On the home one, close Excel completely and then go to Start>Run and type in: excel /regserver Note the space after «excel».
    Did that.It invoked installer and then installer said Configuring Office Xp and after that it closed.Tried to open the file after running the above command but no Luck

    Thanks for all your help.it seems that I am out of luck.Will try to copy the VB module (Found a code for the same- Pearson’s site) and then try to paste that in the problem file.
    Chari

    • #13

    Re: VBA Module not found

    Hi
    Sorry for reverting so late.Since nothing worked,I decided to uninstall MSoffice completely and reinstall.The problem file worked but when I updated the Software(office XP) to SP3,the problem came again.I have now reverted back to Original version and have removed the SP3 update.
    Regards
    Chari

Понравилась статья? Поделить с друзьями:
  • Ошибка module datetime has no attribute strptime
  • Ошибка minecraft не удалось подключиться к миру
  • Ошибка modloader gta sa unknown game
  • Ошибка minecraft не могу войти
  • Ошибка modern warfare 3 unarc