-
I'm really confused here. For my situation, which code should I follow? - Fumei's or Gmaxey's? Can anyone explain what the differences are between those two codings?
OK, nevermind, can someone tell me what's wrong with this coding? The merge part runs fine, but it won't go beyond that. I get an syntax error message in VBA editor at the highlighted line.
--------------------------------
[VBA]Sub mail_merge()
'
' mail_merge Macro
' Macro recorded 10/12/2005 by John
'
With ActiveDocument.MailMerge
.DataSource.FirstRecord = 1
.DataSource.LastRecord = .DataSource.LastRecord
.Destination = wdSendToNewDocument
.Execute
End With
Dim vWords As Variant
Dim i As Long
Dim findString As String
Dim myRng As Range
Set myRng = ActiveDocument.Bookmarks.("Transplant_Type").Range
' or Set myRng = ActiveDocument.Bookmarks("NamedBookmark").Range
findString = InputBox("Type the words to find separated by |")
vWords = Split(findString, "heart|liver|lung|kidney")
For i = 0 To UBound(vWords)
With myRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = vWords(i)
If .Execute Then
'ActiveDocument.Paragraphs(5).Range.Delete
On Error Resume Next
ActiveDocument.Bookmarks("spk_pancrease_only").Range.Delete
ActiveDocument.Bookmarks("bmt").Range.Delete
On Error GoTo 0
End If
End With
Next i
Set myRng = Nothing
End Sub
Sub categories_II_III()
Dim oRange As Word.Range
Set oRange = ActiveDocument.Range.Paragraphs(1).Range
With oRange.Find
findString = "bone marrow;BMT;bmt;stem cell"
vWords = Split(findString, ";")
.Execute
If .Found = True Then
ActiveDocument.Bookmarks("solidorgan").Range.Delete
End If
End With
Set oRange = Nothing
End Sub
Sub pancreas()
Dim oRange As Word.Range
Set oRange = ActiveDocument.Range.Paragraphs(1).Range
With oRange.Find
findString = "pancreas;Pancreas;spk;SPK;PAK;PTA"
vWords = Split(findString, ";")
.Execute
If .Found = True Then
ActiveDocument.Bookmarks("spk_pancreas_only").Range.InsertBefore
oRange.Typetext Text:="For those programs applying for " & _
"pancreas transplant, access to both the simultaneous pancreas " & _
"kidney (SPK) and pancreas (PAK/PTA) UNOS RFI " & _
"must be granted to the BQCT."
End If
End With
Set oRange = Nothing
End Sub
[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules