Thanks for responding. No, it didn't make any difference. Have you ever
seen code just simply not run? Here's the code by the way, but all the
templates I have that contain Document_New events do the same thing on a few
particular computers - the code doesn't execute.
Private Sub Document_New()
Dim oDoc As Document
Dim nListIndex As Long
Dim nCurrRecord As Long
Dim sName As String
Dim sType As String
Dim sPhone As String
Dim sFax As String
Dim sEmail As String
Dim sRecipient As String
Dim sAddress As String
Dim sRegarding As String
Dim sSalutation As String
Dim nLineCount As Long
Dim bUnderline As Boolean
Dim bBold As Boolean
Dim bItalic As Boolean
Dim nStart As Integer
Dim nNext As Integer
Dim ofrmSelect As frmSelect
Set ofrmSelect = New frmSelect
Set oDoc = ActiveDocument
Load ofrmSelect
ofrmSelect.optNone = True
ofrmSelect.lstLawyers.Clear
If ofrmSelect.cmdCancel = True Then ActiveDocument.Close wdDoNotSaveChanges
DoEvents
oDoc.MailMerge.DataSource.ActiveRecord = wdFirstRecord
Do
ofrmSelect.lstLawyers.AddItem
oDoc.MailMerge.DataSource.DataFields("Name")
nCurrRecord = oDoc.MailMerge.DataSource.ActiveRecord
oDoc.MailMerge.DataSource.ActiveRecord = wdNextRecord
Loop Until nCurrRecord = oDoc.MailMerge.DataSource.ActiveRecord
ofrmSelect.lstLawyers.ListIndex = -1
ofrmSelect.Show
If ofrmSelect.optCertified = True Then
ActiveDocument.Bookmarks("bkdelivery").Range.Text = "Via Certified Mail;
Return Receipt Requested"
End If
If ofrmSelect.optFacUS = True Then
oDoc.Bookmarks("bkdelivery").Range.Text = "Via Facsimile and U.S. Mail"
End If
If ofrmSelect.optHand = True Then
oDoc.Bookmarks("bkdelivery").Range.Text = "Via Hand Delivery"
End If
If ofrmSelect.optFacsimile = True Then
oDoc.Bookmarks("bkdelivery").Range.Text = "Via Facsimile"
End If
If ofrmSelect.optUPS = True Then
oDoc.Bookmarks("bkdelivery").Range.Text = "VIA UPS"
End If
If ofrmSelect.optFedex = True Then
oDoc.Bookmarks("bkdelivery").Range.Text = "Via FedEx"
End If
ActiveDocument.Bookmarks("bkRe").Range.Text = ofrmSelect.txtRe
ActiveDocument.Bookmarks("bkSalutation").Range.Text =
ofrmSelect.txtSalutation
ActiveDocument.Bookmarks("bkRecName2").Range.Text = ofrmSelect.txtRecName
If ofrmSelect.boxPaste = True Then
On Error GoTo ErrHandler
ActiveDocument.Bookmarks("bkRecName").Range.PasteAndFormat wdPasteDefault
End If
ErrHandler:
If Err.Number = 4605 Then
MsgBox "The clipboard is empty. You must first select and copy text."
End If
If ofrmSelect.boxOutlook = True Then
Selection.GoTo what:=wdGoToBookmark, Name:="bkRecName"
WordBasic.InsertAddress
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.GoTo what:=wdGoToBookmark, Name:="bkStop"
End If
If ofrmSelect.optNone = True Then
With ActiveDocument.Bookmarks("bkDelivery")
.Range.Paragraphs(1).Range.Delete
.Delete ' remove the bookmark itself, too
End With
End If
If ofrmSelect.txtRecFirm.Text = "" Then
With ActiveDocument.Bookmarks("bkRecFirm")
.Range.Paragraphs(1).Range.Delete
.Delete ' remove the bookmark itself, too
End With
Else
ActiveDocument.Bookmarks("bkRecFirm").Range.Text =
ofrmSelect.txtRecFirm.Text
End If
If ofrmSelect.txtAdd1.Text = "" Then
With ActiveDocument.Bookmarks("bkAdd1")
.Range.Paragraphs(1).Range.Delete
.Delete ' remove the bookmark itself, too
End With
Else
ActiveDocument.Bookmarks("bkAdd1").Range.Text = ofrmSelect.txtAdd1.Text
End If
If ofrmSelect.txtAdd2.Text = "" Then
With ActiveDocument.Bookmarks("bkAdd2")
.Range.Paragraphs(1).Range.Delete
.Delete ' remove the bookmark itself, too
End With
Else
ActiveDocument.Bookmarks("bkAdd2").Range.Text = ofrmSelect.txtAdd2.Text
End If
If ofrmSelect.txtCityStateZip.Text = "" Then
With ActiveDocument.Bookmarks("bkCityStateZip")
' .Range.Paragraphs(1).Range.Delete
.Delete ' remove the bookmark itself, too
End With
Else
ActiveDocument.Bookmarks("bkCityStateZip").Range.Text =
ofrmSelect.txtCityStateZip.Text
End If
If ofrmSelect.txtcc.Text = "" Then
With ActiveDocument.Bookmarks("bkcc")
.Range.Paragraphs(1).Range.Delete
' .Delete ' remove the bookmark itself, too
End With
Else
ActiveDocument.Bookmarks("bkcc").Range.Text = ofrmSelect.txtcc.Text
End If
If ofrmSelect.txtbcc.Text = "" Then
With ActiveDocument.Bookmarks("bkbcc")
.Range.Paragraphs(1).Range.Delete
' .Delete ' remove the bookmark itself, too
End With
Else
Selection.GoTo what:=wdGoToBookmark, Name:="bkBCC"
Selection.HomeKey Unit:=wdLine
Selection.InsertBreak (wdPageBreak)
Selection.TypeParagraph
ActiveDocument.Bookmarks("bkbcc").Range.Text = ofrmSelect.txtbcc.Text
End If
ActiveDocument.Bookmarks("bkRecName").Range.Text =
ofrmSelect.txtRecName.Text
If ofrmSelect.mReturn Then
nListIndex = ofrmSelect.lstLawyers.ListIndex
Unload ofrmSelect
Set ofrmSelect = Nothing
'Unload ofrmSelect
End If
If nListIndex <> -1 Then
oDoc.MailMerge.DataSource.ActiveRecord = nListIndex + 1
sName = oDoc.MailMerge.DataSource.DataFields("Name")
sType = oDoc.MailMerge.DataSource.DataFields("Title")
sPhone = oDoc.MailMerge.DataSource.DataFields("DD")
sFax = oDoc.MailMerge.DataSource.DataFields("Fax")
sEmail = oDoc.MailMerge.DataSource.DataFields("Email")
End If
ActiveDocument.Bookmarks("bkName").Range.Text =
oDoc.MailMerge.DataSource.DataFields("Name")
ActiveDocument.Bookmarks("bkDD").Range.Text =
oDoc.MailMerge.DataSource.DataFields("DD")
ActiveDocument.Bookmarks("bkEMail").Range.Text =
oDoc.MailMerge.DataSource.DataFields("Email")
ActiveDocument.Bookmarks("bkFax").Range.Text =
oDoc.MailMerge.DataSource.DataFields("Fax")
ActiveDocument.Bookmarks("bkSig").Range.Text =
oDoc.MailMerge.DataSource.DataFields("Sig")
nStart = 1
Do
nNext = InStr(nStart, sAddress, Chr(13), vbBinaryCompare)
nLineCount = nLineCount + 1
nStart = nNext + 1
Loop Until nNext = 0
oDoc.Range.InsertAfter (sAddress & Chr(13))
Selection.MoveUntil Chr(9), wdForward
Selection.Expand wdParagraph
oDoc.MailMerge.MainDocumentType = wdNotAMergeDocument
Set oDoc = Nothing
Selection.GoTo what:=wdGoToBookmark, Name:="bkStop"
End Sub