Win 2000 Word 2003 Compile error VB

B

BLeman

When trying to compile and run a macro with Word 2003, the VB compiler
returns an error. The macro code is correct as it will run on other
machines.
It appears that the VB library or system is corrupt. How do I fix this?
Macros will compile and run in Excel on the same computer.
 
B

Beth Melton

A compile error means there is an error in the macro - not an error in
the compiler. Just because it runs correctly doesn't mean there isn't
an error. For example if the error occurs in a line of code that is
never executed when the macro runs you'll not encounter the error.

Now, if the macro complies correctly and runs on another computer then
it could be due to a missing or incorrect reference on the computer
that encounters the error so that's something you may want to check.

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Office 2007 Preview Site:
http://www.microsoft.com/office/preview/default.mspx
Office 2007 Community Articles/Tutorials:
http://www.microsoft.com/office/preview/community/article_archive.mspx

TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 
B

BLeman

:

The Error that is displayed is from Microsoft Visual Basic and is "Compile
Error: Expected: line number or label statement or end of statement". The
actual line it stopped on is the first line: Sub BRL (). The whole macro is
just a test case and is as follows:
Sub BRL()
'
' BRL Macro
' Macro recorded 11/4/2006 by
'
ChangeFileOpenDirectory "C:\RezOvation\"
Documents.Open FileName:="Invoice.rtf", ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
ActiveDocument.Close
End Sub

The data that is actually displayed when the compile stops on the first line
is garbage (misc characters). I don't see any error in the code that would
produce the error.

Thanks

BLeman
 
B

Beth Melton

Looks like you have a line continuation operator missing at the line
that ends PasswordDocument:=""

Here's the corrected code:

Sub BRL()
'
' BRL Macro
' Macro recorded 11/4/2006 by
'
ChangeFileOpenDirectory "C:\RezOvation\"
Documents.Open FileName:="Invoice.rtf", ConfirmConversions:=False,
_
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto,
XMLTransform:=""
ActiveDocument.Close
End Sub

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Office 2007 Preview Site:
http://www.microsoft.com/office/preview/default.mspx
Office 2007 Community Articles/Tutorials:
http://www.microsoft.com/office/preview/community/article_archive.mspx

TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 
B

BLeman

The code was OK, Just made an error when it was copied. The code is as
follows:

Sub BRL()
'
' BRL Macro
' Macro recorded 11/4/2006 by Bert Leman
'
ChangeFileOpenDirectory "C:\RezOvation\"
Documents.Open FileName:="Invoice.rtf", ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
ActiveDocument.Close
End Sub

The error is just as it was described in the previous post. Thanks

BLeman
 
B

Beth Melton

Since it was a copy/paste error then you really haven't pinpointed the
line causing the error. When you encounter a Compile error that means
the Compiler is attempting to translate/compile the code and the
procedure has not been executed. In that case the Sub <Name> will be
highlighted in yellow indicating that line is currently in suspense
since it's not about to execute the macro. This unlike a Runtime
rror - for those you need to looks for the line highlighted in yellow
which is the line that caused the error as the macro was running. For
a compile error, look for the data that is selected (highlighted in
blue) in order to determine the cause of the error.

Did you check for missing references as I previously noted? Also, is
the macro in a general module, such as NewMacros or is it stored
elsewhere?

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Office 2007 Preview Site:
http://www.microsoft.com/office/preview/default.mspx
Office 2007 Community Articles/Tutorials:
http://www.microsoft.com/office/preview/community/article_archive.mspx

TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 
B

BLeman

I have checked and verified the references. The macro is stored in the
Normal-New Macros (Code). When attempting to run the macro from Word, the
Macro Compile error is displayed as previously noted. The screen that is
displayed is titled Normal-BRL (Code) and contains garbage (mostly special or
non printable characters). There is nothing intelligible on the display.
The display is from the VB debugger which comes up next after attempting to
"run" the macro from Word.

BLeman
 
B

Beth Melton

If you are certain you checked the code then have you tried using
Detect and Repair? You can access it from the Help menu from any
Office application.

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 
B

BLeman

The code was machine generated without any keyboard input. As you can see it
is just a simple open file and close file routine. I have done a complete
remove and reinstall of the Office system and also ran the Detect & Repair
again. The system still will not work. Are there any modules or run time
libraries that are not installed by the Office system but are used by the
macro procedure? If so, I suspect that one of them might be trashed. Is
there a list of these from Microsoft that could be downloaded and replaced?

Thanks for your help.
 
B

Beth Melton

There aren't any additional libraries that are needed for
record/playback of macros.

BUT I read through this thread again and this time something caught my
eye (I don't know why I didn't see this before!), previously you
indicated the macro you recorded is stored in Normal-New Macros
(Code). But the error that displays is titled Normal-BRL (Code). That
tells me you have another module in Normal.dot named BRL which I'm
fairly certain is the cause of the error.

When you run the macro and you encounter a compile error in a module
named BRL (you'll see the name in the title bar) and the strange text
is highlighted in blue, then as I previously noted, the error is being
pinpointed for you. If you don't see the Project Explorer on the left
then go View/Project Explorer to turn it on. If the BRL module
contains nothing but garbage then right-click it in the Project
Explorer and select Remove.

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 
B

BLeman

Well, live and learn. Dummy me, you were right. Somehow there were 4
modules in the system with three of them full of garbage. When the macro
tried to run it was loaded from one of the garbage modules. After deleting
them and getting to the right one everything runs as it is suposed to. Thank
you very much for your help.

BLeman
 
B

Beth Melton

You're welcome and I'm glad to hear you have the issue resolved.
Thanks for sticking with me - I'm sure there were a couple of times
you felt I had you going in circles but I've never encountered a
situation in which a compile error was caused by anything other than a
'real' error. This one was a little trickier since you had both a
macro and a module with the same name. In any event, hopefully you
learned more about what you need to look for when an error does occur
and you'll be able to pinpoint the cause faster next time. :)

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top