View Single Post
  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Marty Marty is offline
external usenet poster
 
Posts: 28
Default deleting to end of document in VBA

I tried this, but it did not seem to work. Perhaps it was not getting to the
beginning of the document. However, Doug also sent some code, and that did
work.

Thanks for you help. It helps me to understand what is happening in the code.

-Marty

"Greg Maxey" wrote:

Try:

Sub Scratchmacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng
With .Find
.Text = "[end of transmittal]"
If .Execute Then
With oRng
.Collapse wdCollapseEnd
.End = ActiveDocument.Range.End
.Delete
End With
End If
End With
End With
End Sub

Marty wrote:
Hi-

I have the following VBA code in a mailmerge:

With Selection
.HomeKey unit:=wdStory
.Find.Execute findtext:="[end of transmittal]"
.ExtendMode = True
.Find.Execute findtext:="[end of transmittal]"
.Delete
End With

This will delete all text between (and including) "[end of transmittal]".
But, what I really want to do, is to deletle all text from "[end of
transmittal]" to the end of the document.

How would I change the above to accomplish this?

Thanks,
Marty