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