Compile errors: What's wrong with this code?

D

DFStoneJr

After several years of working with VBA in Excel, I'm now starting to
visit the world of Word. It's driving me nuts. ;)

The following two macros are stored in the same module in Normal.dot:

Sub FileFolderLabels()
Application.MailingLabel.DefaultPrintBarCode = False
Application.MailingLabel.CreateNewDocument Name:="5066",
Address:="", _
AutoText:="ToolsCreateLabels1", LaserTray:=wdPrinterManualFeed,
_
ExtractAddress:=False, PrintEPostageLabel:=False,
Vertical:=False
End Sub

Sub FaxCover()
Documents.Add Template:= _
"C:\Documents and Settings\dstone\Application
Data\Microsoft\Templates\FAX.dot" _
, NewTemplate:=False, DocumentType:=0
End Sub

The former generates this error message: "Compile Error. Expected End
Sub" on the first line.

The latter generates this error message: "Compile error. Only comments
may appear after End Sub, End Function or End Property" before it even
gets to the first line.

I've tried separating them into different modules. I've tried deleting
all blank lines in the code.

What am I missing? Why won't the code execute?
 
D

Doug Robbins - Word MVP

No problem here compiling your code when I copy it into the Visual Basic
Editor and fix up the line breaks.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

DFStoneJr

Well, I copied the code to a new module, then deleted the original
module. They seem to work now. Aaaaaaargh.

Thanks for the response. It helped.
 
D

DFStoneJr

Whatever it was was invisible. The code was pasted from the modules
exactly.

What could "something inappropriate" be? I don't want to waste another
half-day if I don't have to. ;)
 
J

Jonathan West

Whatever it was was invisible. The code was pasted from the modules
exactly.

What could "something inappropriate" be? I don't want to waste another
half-day if I don't have to. ;)

Sounds like you have a corrupt template. I'd export all modules, and import
them into a fresh template, and carry on working from there.

Corrupt templates do happen from time to time. Take a look here.


Combatting Template Bloat
http://www.word.mvps.org/FAQs/MacrosVBA/TemplateBloat.htm


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.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