Close Window   
Free Ebook
Get Your Free Excel
ebook!
Our Top 15 Excel Tutorials
Instant Access!
E-mail:
Subscribe for Free Excel tips & more!
E-mail:
Advertisements



Compile Error In Hidden Module: Thisworkbook

Forum Register
Search Excel Forum Posts, Tutorials, Macros, Tips, and More

You mighthave an add-in under tools>add-ins associated with Project, if you
can't figure out which uncheck all add-ins, then restart excel, if the
problems go away check one at a time (and close and restart excel) until you
get the error again, then you know which one it is and can uncheck ity. Or
you might have something in your xlstart folder, check there as well and
remove anything and restart to see if problem persists.

Regards,

peo sjoblom

"Lloyd" wrote:

> My company currently uses Office XP SP2 and Project 2000 SR1. When we
> uninstall Project 2000, and try opening Excel, we receive the following error
> message:
> Compile error in hidden module: ThisWorkbook
> Can you tell us why are we receiving this error. I looked at Tools -
> References and did not notice anything missing.
>
> Thanks in advance.


View Answers     

Similar Excel Tutorials

Chart Hidden Data in Excel
How to show data from hidden rows and columns on a chart in Excel. When you hide rows or columns of data, a chart ...
Error bars in Charts in Excel
How to add, manage, and remove error bars in charts in Excel. Error bars allow you to show the potential variance ...
Prevent Errors From Appearing in Excel
How to prevent errors from appearing in formulas in Excel. This is especially helpful for the Vlookup function. Sec ...
Remove Vlookup #N/A Error in Excel
How to remove the #N/A error from Vlookup and replace it with a friendly message or a blank cell. Fix the Vlookup ...
Hide Data Within a Worksheet in Excel
In Excel you can actually hide data that is stored within a worksheet. This allows you to show data that is useful ...
Automatically Run a Macro When a Workbook is Opened
How to make a macro run automatically after a workbook is opened and before anything else happens. You need this m ...

Helpful Excel Macros

Delete a VBA Module From Excel
- Delete a VBA macro module from Excel with this macro. This macro allows you to fully remove a macro module from Excel.
Excel Macro to Save a Specific Worksheet as a New File
- This Excel Macro allows you to save a specific worksheet within the Excel Workbook to its own new file. You will be a
Delete All Chart Sheets in Excel - Only Chart Sheets are Deleted - Not Embedded Charts
- Delete all chart sheets and tabs in Excel using this macro. This will only delete the charts and graphs that are in the
Macro to add a New Line to Message Box Pop-up Windows in Excel
- This is a very simple Message Box, pop-up window, macro for Excel that illustrates how to put new lines, the same thi
Save the Current Worksheet as a New Excel Workbook File
- This Excel Macro will save the currently visible/active worksheet (the one that you see when you run the macro) to a

Similar Topics







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.




I have a new client company using a model whose core macros were developed about seven years ago and have been used successfully by well over 1,000 users. (Not to brag - just to illustrate that I don't think it's anything in the VBA code that is the problem.)

Several users at this new company are getting Compile Errors when they attempt to use the first macro. Other users are not having the problem at all. The new company is very small, has no IT dept to speak of, and is very primitive in their Excel use. (Don't know if this is related, but the users who have the problem are both on Excel 2003, and had their macro security settings set to High. I had them reset to 'Medium' and restart Excel.)

I've seen this problem before, so I sent a copy with the VBA code unprotected to one of the users who was experiencing the problems, and asked him to go to the Tools, References so he could check-mark the missing files. But for him 'Tools, References' is grayed out.

So I had him close my model, open a blank one, and go into VBA to check Tools, References. It wasn't grayed out then, and there are a few DLL files I have checked on my PC that weren't even included on his list of options (Microsoft Forms 2.0 Object Library and Ref Edit Control). So I had him use the Browse feature to locate these two files, add them to his list and check them. Then reopen my model --

Same problem, and the Tools, References are still grayed out so I couldn't tell if the 'fix' took or not. then we closed my model, opened a new blank one, and rechecked Tools References -- but the newly-added DLL references weren't there.

Can anyone explain what's going on and what I can do to fix it?


Hello there. I have an issue regarding PHStat2. I managed to install it successfully, but whenever I try to access it, after I enable the macros, I get the message: "Compile error in hidden module: This Workbook" and further "A protected module can't be displayed. This error has the following cause and solution:

There is a compilation error in the code of the specified module, but it can't be displayed because the project is protected.
Unprotect the project, and then run the code again to view the error."

Any ideas how to solve it? I really need to use PHStat2 as I have an exam soon. Thanks in advance.


Hi,

I have searched the forums and found similar posts to mine, but my question is still unanswered.
At my workplace we have spreadsheets which import sales figures from SQL.
A macro runs and adds an extra menu to the toolbar, which gives a button to update the figures.
On a particular machine (Windows 2000 pro/Office XP) when opening these spreadsheets, as soon as I click Enable macros, i get the following error:

compile error in hidden module: This workbook

Lots of people access these spreadsheets daily to check figures including myself and they work fine. It's just on this one machine.

Anyone got any ideas on what might be the problem here?

I am a desktop support technician, but i am only just starting out, and i especially dont know alot about excel.

Many Thanks in advance.


In my VBA Project window I am showing a ThisWorkbook and a ThisWorkbook1 Has anyome seen this before. I am use to seeing just one "ThisWorkBook". I am also getting an error message "compile error in hidden module: ThisWorkbook1" when I open the workbook. How do I get rid of ThisWorkbook1?


Hi,

I have an excel database which links into Outlook and Word via macros to automate sending of e-mails and creating documents, etc. Obviously, I have created the correct VBA references and things have been working fine for a while.

However, this is a shared workbook over a small number of machines and due to a recent upgrade, one of the machines is running Vista and Office 2007, whereas the rest run Office 2000 and NT.

All works well until the workbook is opened and saved on the Office 2007 machine as this then changes all the references to Word 12, Outlook 12, etc, instead of Word 9 as seen in Office 2000. Then, when an office 2000 machine opens the workbook, it has a compile error as it cannot find the office 12 references!!

I have created some code to fix this, which uses the AddFromGuid method, which works ok, e.g.:
Code:

ThisWorkbook.VBProject.References.AddFromGuid _
    "{00062FFF-0000-0000-C000-000000000046}", 9, 3


What I want to do is as excel opens, check for missing references and fix them automatically, which is pretty simple on the face of it. However, as the macro fails due to a compile error all macros stop running, therefore whatever I put in the Open_Workbook event doesn't run.

Does anyone know how to either stop the compiler running on start up, or a way of error handling the compile error??


Hi,

I have been trying to add a few reference libraries in my vba project. It works fine on my computer but I get this error message when I run it on someone else's computer:

Runtime error '1004':
Programmatic access to Visual Basic Project is not trusted.


The code that I used is:
ThisWorkBook.VBProject.References.AddFromFile ("C:\Program Files\Common Files\System\ADO\msado15.dll")

I know that I can avoid this error by going into Tools-> Macro -> Security and check the box that says trust VBE project (or something like that). However, I'd like to add the reference library without having the user to do that.

I also tried to use late binding but since I was intending to use late binding rather than adding a SAS reference library, some of the functions seems to not work...

Anyone have any thoughts on how I can solve this problem?

Thanks a lot for your time.


hi all,

i keep getting this error message come up when running my macro, it was working fine and now this comes up. any ideas??

Is it something to do with the version of excel i was previously using 2000 but now using 2003 with sp3??

Thanks

Jon


I tried everything on the site and the error still comes up on opening and
closing Excel.



Hi All,

I have a workbook that is used by a number of different users accross the company. Some people have PC's running Windows 2003 SP3, some have terminals with either
- Windows 2000 SP4 with Excel 2002 SP3
or
- Windows 2003 SP2 with Excel 2002 SP3
on the server.

On the "Windows 2003 SP2 with Excel 2002 SP3" example the code below won't run. Saying "Compile Error in hidden module." I unlocked the code and re-ran the "Workbook_Open" event but I keep getting "Compile Error: Can't find project or library". I have then checked the references but none have the "Missing" prefix, so I don't know which to look for. Does anyone know what DLL i need to load or should I just get IT to updgrade to SP3?

Many thanks,

Jay

Code:

Private Sub Workbook_Open()

    Dim MyName As String
    
    'Sets the MyName variable to the users Username
    MyName = StrConv(Environ("username"), vbUpperCase)
    
    With Application
        .DisplayAlerts = False
        .ScreenUpdating = False
    End With
    
    'Decides which reports to show each user
    Select Case MyName
    End Select

    Call PopulateReportList
    
    With Application
        .DisplayAlerts = True
        .ScreenUpdating = True
    End With
    
End Sub





I have a spreadsheet with a set of macros. One of the macros used the Microsoft Calendar Control 11 to furnish a popup calendar. However, I have disable this by erasing the page code which referenced the control.

I have given a copy of the spreadsheet to a coworker. Everything worked fine until she got Office 2010, at which point the macros quit working with the error message "Unable to find project or library." Using the VBA References dialog box, I have traced this issue to the fact that the Office 2010 installation on her computer does not have the Calendar Control 11 file. I went into the References dialog & tried to uncheck Microsoft Calendar Control 11, but I get an error message telling me it can't be deleted because it's in use. I've looked through my other macros & can find no references to it. The help box on the error message says to remove the control from the form & then uncheck the box. There are no forms listed in the project window.

Can someone tell me how to find where this may be so I can delete it? While we could just install the control file on her computer, I'd really prefer to clean up the spreadsheet so I don't keep running into this every time I provide a copy to someone.

Any help appreciated.

---GJ Case


Hi,

I am facing an illegal operation error when i try to print any file from
excel (any no. of pages), this happens in stand alone printer as well as a
networked printer.

When we press the print button, it flashes this message, but still prints,
but once the printing is completed, i will have to restart the PC. Due to
this error other applications PRINTING also will NOT HAPPEN and the only way
out is, restart the PC.

This happens not only in EXCEL, it happens in all the MS applications
(outlook, access, front page, powerpoint also).

When I check the print manager (before restart), it will not display my
installed printer. I will have to shutdown and restart. Error msg reads as,
your current printer is not available. SPOOL32.dll msg is also displayed.

If anyone could give me a solution on this, it would be definitely helpful.
Because in a day, this happens atleast 4-6 times which is an obstruction to
the work.

Your reply can be sent to me via my email : nathan_rs@hotmail.com

Regards,
Nathan







We have a macro that exports the data from Project 2010 to an excel file. It works well when we use it on a Windows 7 or a Windows 8 machine, but with Office 2010 installed. But now when I am testing it on a Windows 8 Machine with Project 2010 standard but Office 2013, I am getting a Compile error of Cant find the project or Library.

The macro references Microsoft Excel 14.0 Object Library (under VBA menu - Tools - References ) on the machines that it works fine. But on the Windows 8/Office 2013 machine it references to Microsoft 15.0 Object Library. Is this what is causing the error?

Can someone please help me how to figure this error out? How do change the reference or fix the reference?
Thanks

Every time I open Excel and run any macro for the first time I get an error message "Library Not Found". All I do is reset the macro and everything runs just fine until I restart Excel. I check the References and none are missing and all of my macros run afterwards. Any ideas what causes this error message from a "cold start"?


Hi All

I'm trying to programmatically add and remove the Outlook 11.0 Reference Library in Excel 2003.

So far, I have found the following code which successfuly adds the reference:

Code:

    Dim strGUID As String, theRef As Variant, i As Long
     
     'Update the GUID you need below.
    strGUID = "{00062FFF-0000-0000-C000-000000000046}"
     
     'Set to continue in case of error
    On Error Resume Next
     
     'Remove any missing references
    For i = ThisWorkbook.VBProject.References.Count To 1 Step -1
        Set theRef = ThisWorkbook.VBProject.References.Item(i)
        If theRef.isbroken = True Then
            ThisWorkbook.VBProject.References.Remove theRef
        End If
    Next i
     
     'Clear any errors so that error trapping for GUID additions can be evaluated
    Err.Clear
     
     'Add the reference
    ThisWorkbook.VBProject.References.AddFromGuid _
    GUID:=strGUID, Major:=1, Minor:=0
     
     'If an error was encountered, inform the user
    Select Case Err.Number
    Case Is = 32813
         'Reference already in use.  No action necessary
    Case Is = vbNullString
         'Reference added without issue
    Case Else
         'An unknown error was encountered, so alert the user
        MsgBox "A problem was encountered trying to" & vbNewLine _
        & "add or remove a reference in this file" & vbNewLine & "Please check the " _
        & "references in your VBA project!", vbCritical + vbOKOnly, "Error!"
    End Select
    On Error GoTo 0


But when I try to remove it using the following code, it doesn't work.

Code:

     'Update the GUID you need below.
    strGUID = "{00062FFF-0000-0000-C000-000000000046}"
    
     'Set to continue in case of error
    On Error Resume Next
     
    'Remove the reference
    ThisWorkbook.VBProject.References.Remove strGUID


Does anybody have any suggestions of what I'm doing wrong?

Dion




Hi all,

I am soooo frustrated with issues running my project on Windows 7 64 bit PCs! The ActiveX controls needed registers on Windows 7 32 bit PCs, but not 64 bit.

So, I have changed my UserForm to make use of a Class Module cCalendar instead of DTPicker, to eliminate issues on the PCs of other users.

BUT, here is my new Windows 7 64 bit issue:

When I run my app, I first get this error:

Could not load some objects because they are not available on this machine

when I then click on OK, I get the following error:

Compile error: Can't find project or library

highlighting the project or library that cannot be found: FirstRowAdd (see attached image). This is part of this section of code:



Please Login or Register  to view this content.


This ONLY happens on Windows 7 64 bit PCs.

I would really appreciate all your help in fixing this issue, as well as making my app compatible with ALL OS!

Thanks!

I've been using the MZ-Tools add-in for about two months without issues, but now do not see its toolbar when I run Excel. If I close Excel and restart it (or reboot my computer and then start Excel) and press Alt + F11 to bring up the VBE I get the two sequential MZ-Tools 3.0 error messages shown below:

"The Windows clipboard can not be used. Perhaps it is locked by other application."

"The add-in could not create a button."

Has anyone encountered this problem and/or have a solution?


I have a VBA application in Excel that is used in multiple versions of Excel (2003, 2007, 2010). It is also used on x86 and x64 servers. The crux of the problem is that when a user downloads my application and puts it on an x64 system, there is a reference that points to just the "Program Files" directory instead of "Program Files (x86)". This causes the reference to be missing.

I cannot let this application access the VBA Project due to security reasons.

Is there any way I can trap this error (Compiler Error in Hidden Module or something like that) and just pop up a message box that tells the user that they have to change that reference?


My client upgraded to Excel 2010 and now gets the following error when trying to run one macro within the workbook: "Compile error in hidden module: XXXXX. The error commonly occurs when code is incompatible with the version, platform, or architecture of this application. Click "Help" for information on how to correct this error."

To my eyes, there seems to be not any unusual macro code which can cause the problem (unfortunately I can't right now access the specific row on which the error occurs). There is one pivot table in a hidden sheet which the macro updates among some other small things.
And the weird thing is that on my Excel 2010, I don't get the error at all. The only difference I know is that I have 64-bit Windows and my client has 32-bit. The original Excel file is developed with Excel 2002.

What might cause that error message?


Hi guys

My file works fine when I open it, however, I'm getting this compile message when another user on a different machine tries to open it. I've searched the board and think I understand it to be missing some references when opened on the other person's machine. It doesn't make any sense and it's driving me mad. Does anyone know why?

Thanks in advance

Dave


Hi,

My friend started to use my workbook and everytime he hits F9 to recalculate error comes up " can't find project or library" and it has OK and Help buttons.

I tried googling and searching here but can not find out exactly how to fix it. when I click OK VB references come up and in the list there are no items that have missing next to them. so I dont know when its missing. Also there are a few times that I can not uncheck because they are being used.

Is there anyway I can fix this?

Pleeeeese help us out

Thank you

axg275


I have just written a program for someone with about 3,000 lines of VBA and when they try to open it they said this...

"""
All I get are a long neverending series of error popups such as:

"System Error &H8000FFF (-2147418113). Catastrophic failure."

"Out of memory."

Then the project opens up my Microsoft Visual Basic Debugger to Sheet3 with highlighted text

Then the series repeats."""


I wrote the program on excel for mac 2004, i'm wondering if I wrote code that can't compile with .XML? maybe? also I can't understand, Sheet3 has no subs, so why is data populating into an empty sheet and THEN generating a compile issue (which is what it sounds like)? All code is in modules and userforms (there are 6) , even the function macros I have saved in a separate module. Has anyone come across this problem with 2007 being backwards compatible? Maybe it's just a syntax problem? I have some pictures saved into the sheet for tutorial purposes as well. I don't have access to 2007 so I can't begin to figure this out

TIA


Hello everybody!

I'm having a problem with a missing reference when moving an xlsm file into another computer.
After a little research I've found that the problem is the minor number.
For some reason, in my PC the reference is added with minor = 2 and the target PC needs it with minor=0 (I've checked the minor number in the target PC by fixing the reference by hand and listing the references again).

First of all, why's that difference with minor numbers? The workbook use 8 different references and only one fails to load because of that (I didn't check the other minor and major numbers because didn't fail, but I guess they're the same). The path to the reference (REFEDIT.DLL) is okay, the only difference is the minor number.

Anyway, I've tried to fix this with some code I found on the net and I can't remove the reference!

VB:

Sub AddReference() 
     'Macro purpose:  To add a reference to the project using the GUID for the
     'reference library
     
    Dim strGUID As String, theRef As Variant, i As Long 
     
     'Update the GUID you need below.
    strGUID = "{00024517-0000-0000-C000-000000000046}" 
     
     'Set to continue in case of error
    On Error Resume Next 
     
     'Remove any missing references
    For i = ThisWorkbook.VBProject.References.Count To 1 Step -1 
        Set theRef = ThisWorkbook.VBProject.References.Item(i) 
        If theRef.isbroken = True Then 
            ThisWorkbook.VBProject.References.Remove theRef 
        End If 
    Next i 
     
     'Clear any errors so that error trapping for GUID additions can be evaluated
    Err.Clear 
     
     'Add the reference
    ThisWorkbook.VBProject.References.AddFromGuid _ 
    GUID:=strGUID, Major:=1, Minor:=0 
     
     'If an error was encountered, inform the user
    Select Case Err.Number 
    Case Is = 32813 
         'Reference already in use.  No action necessary
    Case Is = vbNullString 
         'Reference added without issue
    Case Else 
         'An unknown error was encountered, so alert the user
        MsgBox "A problem was encountered trying to" & vbNewLine _ 
        & "add or remove a reference in this file" & vbNewLine & "Please check the " _ 
        & "references in your VBA project!", vbCritical + vbOKOnly, "Error!" 
    End Select 
    On Error Goto 0 
End Sub 


If you like these VB formatting tags please consider sponsoring me in support of injured Royal Marines



I've run this in debug mode and stopped it after the Remove line was executed, went to see if the reference was actually removed but was still there so I guess that's why it isn't added again later (because it's already there).

What am I missing?

Hello,

This code allows you to add reference to a specific library on the fly.

Code:

Sub AddReference() 
     'Macro purpose:  To add a reference to the project using the GUID for the
     'reference library
     
    Dim strGUID As String, theRef As Variant, i As Long 
     
     'Update the GUID you need below.
    strGUID = "{00020905-0000-0000-C000-000000000046}" 
     
     'Set to continue in case of error
    On Error Resume Next 
     
     'Remove any missing references
    For i = ThisWorkbook.VBProject.References.Count To 1 Step -1 
        Set theRef = ThisWorkbook.VBProject.References.Item(i) 
        If theRef.isbroken = True Then 
            ThisWorkbook.VBProject.References.Remove theRef 
        End If 
    Next i 
     
     'Clear any errors so that error trapping for GUID additions can be evaluated
    Err.Clear 
     
     'Add the reference
    ThisWorkbook.VBProject.References.AddFromGuid _ 
    GUID:=strGUID, Major:=1, Minor:=0 
     
     'If an error was encountered, inform the user
    Select Case Err.Number 
    Case Is = 32813 
         'Reference already in use.  No action necessary
    Case Is = vbNullString 
         'Reference added without issue
    Case Else 
         'An unknown error was encountered, so alert the user
        MsgBox "A problem was encountered trying to" & vbNewLine _ 
        & "add or remove a reference in this file" & vbNewLine & "Please check the " _ 
        & "references in your VBA project!", vbCritical + vbOKOnly, "Error!" 
    End Select 
    On Error Goto 0 
End Sub


I would like to modify the procedure so that it takes two optional variables.

First variable should be the workbook object to apply the reference and second variable the reference's GUID string. (in the above example {00020905-0000-0000-C000-000000000046}).

Also another question, if I add some references in the VBA editor, are all these automatically applied to all subsequent workbooks I create?

many thanks
Andy


I was trying to remove missing references from VBA Projects. For example,
this is the code I use if I want to remove "Microsoft ActiveX Direct Object
2.7 Library"

The error message I got is "Programmatic access to Visual Basic Project is
not trusted". Could anybody help me out? Thanks a lot!

---------------------------------------------------------------------
Sub removeRef()

Dim Wkb As Workbook
Set Wkb = ThisWorkbook
With Wkb.VBProject.References
.Remove (msado15.dll)
End With
End Sub
----------------------------------------------------------------------