AyeSee
01-24-2011, 01:04 PM
Heyhey,
I've been trying to have code delete a variable amount of my document (which can include pictures and tables). All of these need to be deleted depending on one condition. The problem is I have trouble selecting the lower and upper borders of what I need to delete.
I have set key words so that I can find the starting and end points, but I am having trouble selection everything in between both.
This is an illlustration of what I am trying to do (initial state):
----------------------------------
Bla bla bla bla bla bla bla bla.
keyFixedRate
Bla bla bla bla bla. Bla bla bla bla:
Bla bla bla bla bla.
Bla bla ble ble ble bla bla bla.
keyFixedRate
Bla bla bla bla bla bla bla bla.
----------------------------------
So, everything in between both keywords I have identified as "keyFixedRate" need to be deleted (inclusively). The final result should be like this:
----------------------------------
Bla bla bla bla bla bla bla bla.
Bla bla bla bla bla bla bla bla.
----------------------------------
I have found somethign similar that seems to do what I am looking for, but I can't seem to modify the code appropriately.
Dim myRange as Range
Set myRange = Selection.Range
myRange.End = ActiveDocument.Range.End
myRange.End = myRange.Start + Instr(myRange, "#")
myRange.Delete
Many thanks in advance...
Alex
I've been trying to have code delete a variable amount of my document (which can include pictures and tables). All of these need to be deleted depending on one condition. The problem is I have trouble selecting the lower and upper borders of what I need to delete.
I have set key words so that I can find the starting and end points, but I am having trouble selection everything in between both.
This is an illlustration of what I am trying to do (initial state):
----------------------------------
Bla bla bla bla bla bla bla bla.
keyFixedRate
Bla bla bla bla bla. Bla bla bla bla:
Bla bla bla bla bla.
Bla bla ble ble ble bla bla bla.
keyFixedRate
Bla bla bla bla bla bla bla bla.
----------------------------------
So, everything in between both keywords I have identified as "keyFixedRate" need to be deleted (inclusively). The final result should be like this:
----------------------------------
Bla bla bla bla bla bla bla bla.
Bla bla bla bla bla bla bla bla.
----------------------------------
I have found somethign similar that seems to do what I am looking for, but I can't seem to modify the code appropriately.
Dim myRange as Range
Set myRange = Selection.Range
myRange.End = ActiveDocument.Range.End
myRange.End = myRange.Start + Instr(myRange, "#")
myRange.Delete
Many thanks in advance...
Alex