delete a sentence in Word

zoog25

Active Member
Joined
Nov 21, 2011
Messages
418
Hello all,

Have a macro that I use to fill out a form in Word. The problem is that i have a select statement in the code that if a certain cell has certain words it will fill out a textbox. My issue is that if the word "Cash" appears in that cell then a sentence containing the particular named textbox needs to be deleted. Here is the select statement that i'm using. I don't know how to make it work so it deletes the sentence in quesiton.

VBA Code:
Select Case TPws.Cells(rw, "V")
    Case "Bond"
        Wordapp.ActiveDocument.FormFields("TXMaintID").Result = "Bond # " & TPws.Cells(rw, "X").Value   'Maintenance Bond ID # Entry
        Wordapp.ActiveDocument.FormFields("TXMaintID1").Result = "Bond # " & TPws.Cells(rw, "X").Value  'Maintenance Bond ID # Entry
        Wordapp.ActiveDocument.FormFields("TXMaintID2").Result = "Bond # " & TPws.Cells(rw, "X").Value  'Maintenance Bond ID # Entry
    Case "LOC"
        Wordapp.ActiveDocument.FormFields("TXMaintID").Result = "Letter of Credit (LOC) # " & TPws.Cells(rw, "X").Value 'Maintenance LOC ID # Entry
        Wordapp.ActiveDocument.FormFields("TXMaintID1").Result = "LOC # " & TPws.Cells(rw, "X").Value   'Maintenance LOC ID # Entry
        Wordapp.ActiveDocument.FormFields("TXMaintID2").Result = "LOC # " & TPws.Cells(rw, "X").Value   'Maintenance LOC ID # Entry
    Case "Cash"
        Wordapp.ActiveDocument.FormFields("TXMaintID").Result = "Cash Bond Per Receipt # " & TPws.Cells(rw, "BD").Value 'Maintenance LOC ID # Entry
        Wordapp.ActiveDocument.FormFields("TXMaintID1").Result = "Cash Bond Per Receipt # " & TPws.Cells(rw, "BD").Value   'Maintenance LOC ID # Entry
        Wordapp.ActiveDocument.FormFields("TXMaintID2").Range.Sentence.Range.Delete
End Select

The .Range.Sentence.Range.Delete is the issue. i modified it from another line that had .Range.Paragraphs(1).Range.Delete.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,214,945
Messages
6,122,395
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top