Macro fine in Word 2000... breaks in Word 2002...?

K

Kenneth

Howdy,

I recently moved from Office 2000, to Office XP.

I have a bunch of macros that I built (in Word 2000) by
recording, and tweaking, rather than by having any real
understanding of VBA.

They worked fine, but...

Now that I run Word 2002, some of the macros choke.

The one below (with apologies for all the junk my recording
method includes) hangs at the pause that I have marked with
"XXXX", but will not run if I rem that line out.


'
' NameTagsFirst Macro
' Macro created 5/30/2002 by Kenneth
'
'
Documents.Add Template:= _
"F:\Templates\Label 4x2.dot" _
, NewTemplate:=False, DocumentType:=0
Documents.Open FileName:="Z:\Data\let.txt",
ConfirmConversions:=False, ReadOnly:= _
False, AddToRecentFiles:=False,
PasswordDocument:="", PasswordTemplate:= _
"", Revert:=False, WritePasswordDocument:="",
WritePasswordTemplate:="", _
Format:=wdOpenFormatAuto
Selection.TypeText Text:="First" & vbTab
Selection.TypeParagraph
ActiveDocument.Save
ActiveWindow.Close
Selection.Font.Size = 36
Selection.Font.Bold = wdToggle
ActiveDocument.MailMerge.MainDocumentType =
wdFormLetters
ActiveDocument.MailMerge.OpenDataSource
Name:="Z:\data\let.txt", _
ConfirmConversions:=False, ReadOnly:=False,
LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="",
WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:="",
SQLStatement:="", SQLStatement1 _
:=""
ActiveDocument.MailMerge.EditMainDocument
ActiveDocument.MailMerge.Fields.Add
Range:=Selection.Range, Name:="First"
Selection.TypeParagraph
' ActiveDocument.MailMerge.Fields.Add
Range:=Selection.Range, Name:="Last"
SendKeys "~"

ActivePrinter = "OKI"

With ActiveDocument.MailMerge
.Destination = wdSendToPrinter
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True XXXXXXXXXXXXXXXXXXXXXXX
End With

ActivePrinter = "Printer Color"

ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Application.ScreenUpdating = True
Application.Quit


Might you assist in getting this to run properly?

Many thanks,
 
D

Doug Robbins - Word MVP

In itself, that command should not cause a problem. I suspect that it is
more something to do with the ActivePrinter = "OKI"
line of code. Is that printer available on the system that you are now
using?

--
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
 
K

Kenneth

In itself, that command should not cause a problem. I suspect that it is
more something to do with the ActivePrinter = "OKI"
line of code. Is that printer available on the system that you are now
using?

--
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

Hi Doug,

Yes, "OKI" is a valid printer name, and it works with other
macros.

The debugger lights up the pause line.

With that, is it still possible that another line is the
culprit?

Thanks,
 
D

Doug Robbins - Word MVP

The pause is optional. Its purposem when set to True is to enable the
display a troubleshooting dialog box if a mail merge error is found. So you
could delete it.

I think it probably defaults to True. If is it false, and there are mail
merge errors, they will appear in the document.


--
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
 
K

Kenneth

The pause is optional. Its purposem when set to True is to enable the
display a troubleshooting dialog box if a mail merge error is found. So you
could delete it.

I think it probably defaults to True. If is it false, and there are mail
merge errors, they will appear in the document.

Hi Doug,

I can't test this now (because I can't get the macro to
run), but, I do know that when it ran successfully, it
failed if I removed the pause line.

I suspect that my next step will be to start again by
recording, and tweaking.

I'll be back if I have further trouble doing that, and
sincerely appreciate the help you have provided.

All the best,
 

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

Similar Threads

4198 debug 0
Macro fine in W2000... Breaks in W2002...? 0
macro 2 issues 0
mailmerge recorded macro 0
double merge 2
Counting Merged Records 1
Printer not there 1
Saving Files 2

Top