Email:      Pass:    Pass?

Free Excel Forum

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.


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.

Similar Excel Video Tutorials

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.
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
Automatically Run a Macro so Many Seconds, Minutes, or Hours After an Excel Workbook has been Opened
- Run a macro after a certain amount of time has passed since the Excel workbook was opened. This means that you can set
Automatically Run a Macro at a Certain Time - i.e. Run a Macro at 4:30PM every day
- Automatically run an Excel macro at a certain time. This allows you to not have to worry about running a macro every da
Delete Hidden Rows in a Workbook
- This macro will delete hidden rows from every worksheet in an entire workbook. However, note that this will only delete

Similar Topics


I am running M S Office 2003 on Vista Home Premium.
Suddenly. i have started getting the error

Compile Error In Hidden Module : Thisworkbook

while opening excel.

Pl. help.



I keep getting that message everytime I open and then close excel. I think it has something to do with Acrobat as it started once I loaded Acrobat onto my computer but I do not know how to make it go away. Word and Powerpoint work just fine.

When I click on HELP next to it, I get the following message:

Compile error in hidden module: (module name)
A protected module cannot be displayed. The error has the following cause and solution:
- There is a compilation error in the code of the specified module, but it cannot be displayed because the project is protected.
- Unprotect the project and then run the code again to view the error
For additional information, slect the item in question and press F1.

I am not technical at all and totally unsure of what to do. Any help would be much appreciated.


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 receive an error when I open excel stating: "
Compile error in hidden module: AutoExecNew" and I receive an error message
when I exit excel which states "Compile error in hidden module: DistMon."
It does not report any error to the event log. Any help in fixing these error
would be greatly appreciated. Thanks.

Each time I open or close Excel I receive the following error
Microsoft Visual Basic
Compile error in hidden module: DistMon

I am not sure how to fix this?[/img]

In my excel file i have a module that when i save the document that module runs and deletes the code located in "ThisWorkbook".
The problem is: in office 2007 works just fine, but in office 2003 i get un error message.
The code is:


Sub DeleteWorkbookEventCode()
''Needs Reference Set To _
    "Microsoft Visual Basic For Applications Extensibility"
    With ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule
            .DeleteLines 1, .CountOfLines
    End With
End Sub

The bold part of the code seems to be the problem.
The message i receive is:
run-time error '1004':
Programmatic access to Visual Basic Project is not trusted.
Is there any solution for this?

I have looked at similar posts but they don't help, mailnly because I don't understand the technical data/code.
The box appears every time I start Excel, first it was with Version 2003 and now it's the same in 2007!
The full texts are;
compile error in hidden on opening and;
Compile error in hidden module: dist.mon on closing.
I've looked for the two sub text's names but Vista search engine is so ridiculous as to be useless as far I can see.
Any help for someone who is just an end user, like Paddington Bear, " A bear of little brain".
I have tried re-installing Excel, didn't help.


I have a Windows XP laptop with Office 2003 installed. When you launch Excel
a Visual Basic error comes up and says "Compile error in hidden module:
AutoExecNew" Can anyone tell me how to fix this problem? I looked at the
knowledgebase and it says it has to do with an Adobe update. I tried
updating Adobe, I tried uninstalling Adobe, I tried uninstalling and
reinstalling Office, and nothing gets rid of the error.
Any suggestions are greatly appreciated!

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?

This is for MSWORD 2003!!!!!

1) I'm trying to automate updating of VB Projects from a Revised SOURCE document into multiple TARGET document(s); one document at a time.
2) I used (Copy A Module From One Project To Another) as starting code.
3) Everything works OK, except for the "ThisDocument" module. For this module, you can't import the code directly into it, since it can't be deleted. Therefore, you have to insert code into a TEMP module, then delete all the lines from the target "ThisDocument" module, then either .InsertLines or .AddFromFile to copy code lines from the TEMP module into the now empty target "ThisDocument" module.
4) Word crashes, though, when either of these two instructions are executed. From internet, got the idea that when code is added from the top down, that it sees "Sub ABC()" w/o the "End Sub" causing a compile error which causes the crash. So, I tried the idea of copying the lines (one line at a time, in a For ... Next loop) from the BOTTOM UP!
5) But, it still crashes. If I step thru it one line at a time, I find that it crashes when it comes to a line that has the COTINUATION DASH (" _") at the end of the line. This causes a compile error and a crash.
6) In the VB Editor, if I go to Tools / Options / Editor and UNCHECK the "Auto Syntax check" box, AND Tools / Options / General and UNCHECK the "Compile on Demand" box, then it DOESN'T crash.
But, I'd rather avoid this special steps, if there is some other trick out there to make this work. ... Any ideas on better ways to do this????? ... Thanks, sauerj

hi excel gurus!

i m working on an excel 2007 workbook with ms project functionality. in order to be able to use ms project from within excel i m using early binding. for those who dont know what early binding is:

this works fine if the user has ms project installed on his/her pc.

if the user does not have ms project installed i remove the broken references. this works fine.

but my problem is that when i remove the reference to ms project, my vba project will not compile correctly. thus each time when a user opens the workbook the user gets a "compile error in hidden module" , since the functions of ms project are not available.

for example i get a compile error in the following source code:


Public Function getResID(ResName As String, ActiveProject As Project) As Integer
    Dim res As Resource
    For Each res In ActiveProject.Resources
        If = ResName Then
            getResID = res.ID
            Exit Function
        End If
        getResID = -1
End Function

i just want to know what i can do to prevent the compile error? would the use of late binding remove the problem? actually i dont want to use late binding since my source code is already very complex and it would be a huge effort to change it..

would be thankful for any help!

kind regards

Hello everybody,

Is it possible to show a message box when a workbook is opnened in version 2010?
I would like to give users some instructions for an error that occurs when opening in 2010.

Some features I used aren't recognized in 2010 and gives the error:
"Compile Error: Can't find project or library"

This can be solved by following these instructions:
1. Open the database or application.
2. Open a module in Design view or press ALT+F11 to switch to the Visual Basic Editor.
3. On the Tools menu, click References.
4. Clear the check box for the type library or object library marked as "Missing:"

Even better still would be if these steps can be done utomatically

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.

Help, I am getting the following message when I launch Excel, and a further
message when I close it. Other than that it seems to work OK. But I am fed
up having to close the messages.

On Launch:
Compile error in hidden module: AutoExexNew

On Closing
Compile error in hidden module: DistMon

The help file mentions something about unprotecting modules?
I am not an expert in Excel, Home User.

Hello, Just need some direction in figuring out why I have a compile error in hidden module :ThisWorkbook. Ive been using the same excel spreadsheet ( which contains quite a bit of code) on 7 computers for years and all of a sudden I'm getting this error but only on 4 of the computers.. Any Ideas or Suggestions?


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?


I have a spreadsheet file on opening, it gives an error message as "compile error in hidden module: Module1".

Can you please help in getting out of this error message.

Recently had to recover my system, WIN XP SP2. Reinstalled office 2007. When I run excel I get the message: Compile error in hidden module TBRun9 . After I click on the OK box, the program seems to work all right. Can someone tell what this means and how to fix it?


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.:

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 Folks.

I'm trying to run a UserForm (any UserForm actually!) on a PC using Vista, with Office 2000. I'm continuously getting the error message 'Compile Error - Project or Library Not Found'. Having searched through some old threads, I've found myself looking at the 'Tools - References' pop-up, but am unsure as to what needs ticking. Furthermore, after several house moves, I can't find the Office installation disk - so couldn't update from the disk anyway.

Just ticking the boxes doesn't seem to work...(!!??)

I've run UserForms on this PC before, so something's changed...!!

Any help greatly appreciated.

Many thanks,


I am a novice at VB and know just enough to be dangerous. I have a pretty complex spreadsheet with many macros. One macro (called "Save a Copy"), creates a copy of the workbook, saves it into a seperate folder, and names it with the current date and the contents of a particular cell. It works perfect on my machine using Excel 2003 SP3. One of my users has Excel 2002. When she hits the "Save a Copy" macro button, she gets a compile error stating "Can't find project or library". If she hits Debug, it leads her to what appears to be an issue with the Format command within the code. This occurs when it tries to format the date before performing the save. I discovered somewhere that if I close the debug screen, go back to the VB screen and go to Tools>References, I see that "MISSING:Microsoft Outlook 14.0 Object Library" is checked. If I uncheck that box and go back to the spreadsheet, the "Save a Copy" macro will work and not present the compile error. But, it will only work during THAT Excel session only. If I close and restart Excel, the "Save a Copy" macro will error out again and I have to go back to VB and uncheck that box again. Can anyone explain what is happening and how I can cure this problem? Any assistance is greatly appreciated.

Here is my code.

Sub SaveACopy()
' Create new f1o1lder if it doesn't exist
    If Dir("C:\IRQTArchive") <> "" Then MkDir "C:\IRQTArchive"
' Define the format of today's date
    Dim Today
    Today = Format(Now, "mmddyy")
    Dim Time
    Time = Format(Now, "hhmmss")
' Define the file name structure
    Dim sFileName As String
    sFileName = Sheets("Price Workup").Range("G26").Value & "-" & Sheets("Price Workup").Range("A30").Value & "-" & Today & "-" & Time
' Change the date to permanent
    Application.ScreenUpdating = False
    Sheets("Price Workup").Range("G23").Copy
    Sheets("Price Workup").Range("G23").PasteSpecial (xlPasteValues)
    Sheets("Price Workup").Range("H23").Copy
    Sheets("Price Workup").Range("H23").PasteSpecial (xlPasteValues)
  ' Save the workbook
    ThisWorkbook.SaveCopyAs Filename:="C:\IRQTArchive\" & (sFileName) & ".xls"
    Filename = sFileName
 '   Reset Date cell to =Now()
    Sheets("Price Workup").Range("G23") = "=Now()"
    Sheets("Price Workup").Range("H23") = "=Now()"
    Selection.NumberFormat = "h:mm AM/PM"
 ' Define the MessageBox to tell the user it worked ok and the name of the new file
     Dim Message As String
 ' Defines "Message" as the string for the MsgBox command
' Note: strFileName is the filename and Chr(13) is a paragraph character
     Message = "Your file has been saved in the root of the C-drive.  The file path is as follows: '" & "C:\IRQTArchive\" & sFileName & "'"
 ' Display MessageBox
     MsgBox (Message)
End Sub

Whenever i open excel i get this message:
Microsoft Visual Basic
Compile error in hidden module: AutoExecNew

And i get this one whenever i close excel:
Microsoft Visual Basic
Compile error in hidden module: DistMon

I can still use the progam but it runs slow. any ideas on how to solve it?

Hi All!

Ok I've created a database of sorts with user login, userforms .. the whole 9. (with the help of this site) THANKs!!

However, depending on who tries to open the file they can get a message :

Compile errror in hidden module: sheet1
Compile error in hidden module: userform1

I am working with excel 2003 sp2

The people who get error messages are working with excel 2003 (no sp) & excel 2003 sp3.

I am working with excel 2003 sp2.. and do not get this message, others with lower version do not get it either.

Is there some download for this?

Thank you!!

After hours of work with a spreadsheet, my computer suddenly froze and I had to restart. When I tried to open the xls file again, I got the message right after seeing the spreadsheet:

"Microsoft Office Excel has encountered a problem and needs to close. We are sorry for the inconvenicence."

Excel then tries to restart, but the same error/error message occurs, and this loop continues...

Any thing I can do to save the file?