Solved

Compile Error in Hidden Module Running Macros in Word 2010

Posted on 2011-03-16
21
3,113 Views
Last Modified: 2012-06-21
I am testing Word 2010 with our current custom vba macros written for Office 2003.  They are located in a template called legal.dot which loads in the Word startup folder.  When I try to run any macro I get the error: Compile Error in Hidden Module THis error commonly occurs when code is incompatible with the version, platform or architecture of the application.....

I know it is not the code because if I copy all of the macros into my normal.dot & run from there they all run without a problem.  I have the startup folder & the folder where the templates are loading from as a trusted location source but still cannot run?  Any suggestions what I can try?  
0
Comment
Question by:leinig
  • 9
  • 7
  • 4
  • +1
21 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
Comment Utility
Ensure all word documents / applications are closed then ...

Try opening the template in word for edit.  Now try and run one of the macros in another document and it should give some indication of what is happening.

Chris
0
 
LVL 59

Expert Comment

by:Chris Bottomley
Comment Utility
ALso if the template code is protected, after opening it and before doing anything else nlock the project.

Chris
0
 
LVL 13

Expert Comment

by:Stacy Brown
Comment Utility
Try resaving your Legal.dot in Word 2010 as a Legal.dotm file.  

Also, check your macro security settings
0
 

Author Comment

by:leinig
Comment Utility
Unfortunately neither suggestion above has helped.  Macro Security Settings is set to Enable All.  To clarify a little bit more.  I have one .dot (also tried .dotm) that loads in my Word startup folder called legal.dot.  In it resides numerous custom macros.  That being said & in looking further, the error seems to happen only on the macros that load a form with questions.  For instance we have a macro called ELetter.  All that macro does is call a form (frmelet).  That form just has some questions you answer & once done you click ok it opens a document and populates it with the answers you typed in from the form.  The form loads fine & you can answer all the questions but once you hit ok you receive the Compile in Hidden Module error.  As stated earlier if I take the macros (in this example eletter & frmelet) & put in normal.dotm they run without a problem.  So it has to be something with some kind of permissions or protection of that legal.dot in startup.  Can't imagine what though because I run it this way on 100s of machines using Word 2003 & have tried it on 2007 without issues also??  
0
 
LVL 59

Assisted Solution

by:Chris Bottomley
Chris Bottomley earned 150 total points
Comment Utility
Neither suggestion helped ... so with the template file open as the first action, aand unprotected you still get a fsil but no breakpoint then repeat with the other template ... a compile error ought to give some info!

Chris
0
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
leinig: For a faster resolution and keeping the experts from guessing what may have been causing this, could you please upload your file so that we can test it on our machines?

Sid
0
 

Author Comment

by:leinig
Comment Utility
Ok attaching macro & templates.  Put the one called legaldm.dot in word 2010 startup folder.  put the other dots in folder c:\winword\template (or put them anywhere you'd like and just edit fle path in the macros.  Thanks everyone for all your input so far.  Am going to try and find another machine to put 2010 on here and test there also.   macros.zip
0
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
There are 6 files in the zip. which ones should we be looking at? 2010legaldm.Dot?

Sid
0
 

Author Comment

by:leinig
Comment Utility
2010legaldm.dot hold the macros.  the other 5 files are the templates called by the macro
0
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
Ok I will be using 2010 in another hour or so and then I will test it.

Sid
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
>>>I know it is not the code because if I copy all of the macros into my normal.dot & run from there they all run without a problem.

Well. It is the code :)

In the form "frmelet" in the click event of the optYes, you mentioned

cmbdirectdial.Visible = True

I couldn't find that control.

If you comment out that line like I did below then you will not get any errors :)

I guess you meant cmbdelivery and not cmbdirectdial?

Sid

Private Sub optYes_Click()
    If Optyes.Value = 1 Then
        Txtdirdial.Visible = True
        Lblchoose.Visible = True
        Lbldirdial.Visible = True
        txtinitials.Visible = True
   
    Else
        Txtdirdial.Visible = False
        Lbldirdial.Visible = False
        Lblchoose.Visible = False
        'cmbdirectdial.Visible = True
    End If
End Sub

Open in new window

0
 

Author Comment

by:leinig
Comment Utility
I will give it a try.  I did not write all of these macros & the ones I did were written years ago.  I didn't even check the code because as I mentioned if I put the macros into normal.dot they all ran without an issue.  I will check this out on Monday & post results.

Thanks.
0
 

Author Comment

by:leinig
Comment Utility
Web-ex I was participating in ended early.  I commented out that line.  reloaded legaldm.dot.  Run the Eletter macro.  Same issue.  
0
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
Check if all control names are correct. Also check the exact thing that you are doing when you get an error for example what and where do you click when that error happens?

Sid
0
 

Author Comment

by:leinig
Comment Utility
I will examine code on Monday.  I don't receive the error until I click OK on the form which essentially is pulling in the .dot & then populating the fields on that .dot with the stored info from the form variables.  Thanks.  
0
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
There are many coding errors in that file.

For example

.name = Arial

should be

.name = "Arial"

I am going through all the files and it may take some time.

Sid
0
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 350 total points
Comment Utility
Ok to summarize it.

In document 2010legaldm.dot

Replace  

.Alignment = wdAlignParagraphFull

with

.Alignment = wdAlignParagraphCenter

as the constants available are

   wdAlignParagraphLeft
   wdAlignParagraphCenter
   wdAlignParagraphRight
   wdAlignParagraphJustify

Similarly for

.name = TimesNewRoman

Change that to

.name = "TimesNewRoman"

I have updated the file. Please test it for me.

Sid


2010legaldm.dot
0
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
Also one last thing

Also in the Form "frmletter" and "frmletterNew", comment the line

cmbdirectdial.Visible = True

That should take care of all the errors in that file.

Sid
0
 
LVL 59

Expert Comment

by:Chris Bottomley
Comment Utility
Assuming that is the lot then well done Sid, I must admit to losing interest when there was no errors being reported and no response to my comment to check the second file.

Looks like there were just a few errors to be found!

Chris
0
 
LVL 30

Expert Comment

by:SiddharthRout
Comment Utility
Yeah there were many errors. I am surprised when the OP says that there was no errors in the earlier versions as those errors will error out in any version.

The only thing is that I have to switch between OS to test the files out.

Sid
0
 

Author Comment

by:leinig
Comment Utility
I appreciate everyone's time looking at this.  Downloaded file & it appears to work so thank you.  I want to reiterate that these macros are used all day long here in Word 2003 exactly as they exist in the template I provided you along with dozens of others with no issues.

I did open the file as suggested Chris and did see an error on the font name but before I could post results Sid was assisting & making suggestions.  Also as indicated earlier I did not write all of these macros and the ones I originally did write were way back in Word 2000 days so again I apologize for not understanding where the issues were.  I am a novice self-taught at best.  Hence my coming to the experts.  
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

771 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

8 Experts available now in Live!

Get 1:1 Help Now