Solved

Compile Error in Hidden Module Running Macros in Word 2010

Posted on 2011-03-16
21
3,144 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
ID: 35154051
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
ID: 35154184
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
ID: 35157466
Try resaving your Legal.dot in Word 2010 as a Legal.dotm file.  

Also, check your macro security settings
0
 

Author Comment

by:leinig
ID: 35157768
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
ID: 35158310
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
ID: 35162763
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
ID: 35164992
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
ID: 35165244
There are 6 files in the zip. which ones should we be looking at? 2010legaldm.Dot?

Sid
0
 

Author Comment

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

Expert Comment

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

Sid
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35167863
>>>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
ID: 35168219
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
ID: 35168419
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
ID: 35168561
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
ID: 35168741
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
ID: 35170471
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
ID: 35170495
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
ID: 35170504
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
ID: 35171225
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
ID: 35171235
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
ID: 35183612
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to make a exe file from access 2013 database 5 148
Access DB on open (All Objects) 5 61
stop word moving down 2 49
In MS Word, rename styles in a batch 9 42
The canonical version of this article is on my web site here: http://iconoun.com/articles/collisions/ A companion presentation is available here: http://iconoun.com/articles/collisions/Unicode_Presentation.pdf
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

932 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

18 Experts available now in Live!

Get 1:1 Help Now