Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Compile errors: What's wrong with this code?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DFStoneJr@yahoo.com - 16 Mar 2006 18:56 GMT
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?
Doug Robbins - Word MVP - 16 Mar 2006 20:21 GMT
No problem here compiling your code when I copy it into the Visual Basic
Editor and fix up the line breaks.

Signature

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

> After several years of working with VBA in Excel, I'm now starting to
> visit the world of Word.  It's driving me nuts. ;)
[quoted text clipped - 29 lines]
>
> What am I missing?  Why won't the code execute?
DFStoneJr@yahoo.com - 16 Mar 2006 21:21 GMT
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.
Jezebel - 16 Mar 2006 23:22 GMT
It means you had something inappropriate preceding the macro within the
module.

> 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.
DFStoneJr@yahoo.com - 17 Mar 2006 04:19 GMT
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. ;)

> It means you had something inappropriate preceding the macro within the
> module.
[quoted text clipped - 3 lines]
> >
> > Thanks for the response.  It helped.
Jonathan West - 17 Mar 2006 14:58 GMT
> 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

Signature

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 

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.