Re: Select Tool in Macro ??

07-10-2005, 12:00 AM
Thanks loads!! BTW - Its not my choice to use tabs - I'm trying to get rid
of them, actually. They often arise in tab delimited files as you no doubt
know. AND I'm not looking to delete text between tabs - that was just an
example. I want to be able to delete text between "Here" (current curser
location) (and probably result of a Find action) and "There" (text string
xxx for example) (and result of another Find action). I was trying macros
(this operation must repeat hundreds of times in a long document) but it
doesn't seem to be able to "Select" and delete like I would expect. Now
comes Klaus with a most reasonable idea - use find and replace! Duh - I
don't know why I didn't think of this! I tried the example and it didn't
work immediately, but it sure gave me some ideas - so I now just do Find -
^t*^t and replace with [blank]. Seems to work, but am I missing something
by not using all those swear words ((^t)[!^13]@(^t)\1\2)??

Thanks again! (Wowser - there's a lot more power in the search&replace than
I had noticed!!)


"Klaus Linke" <> wrote in message
Hi Bob,

Hmm... Professional Word users will tell you to avoid tabs altogether.
Then why should Word offer a special built-in function to delete stuff
between two tabs?

BTW, you can delete the stuff between the next two tabs with Find/Replace,
similar to the macro Greg posted:
Edit > Replace, check "Match wildcards",
Find what: (^t)[!^13]@(^t)
Replace with: \1\2
You can use the macro recorder to create a macro from this without writing a
line of code.

If you have a "table" done with tabs, you can also use
Alt+LeftMouseButton+Drag to select a "column" and delete it.


"InOverMyHead" <> schrieb im Newsbeitrag
> "Greg" <> wrote in message
> > Bob,
> >
> > You don't really need to select the text to delete it. Here is a macro
> > that finds text between the first and second tabs following the
> > insertion point and deletes the text while leaving the tabs.
> >
> > Sub DeleteTextBetweenTabs()
> > Dim myRange As Range
> > Set myRange = Selection.Range
> > myRange.End = ActiveDocument.Range.End
> > With myRange.Find
> > .ClearFormatting
> > .MatchWildcards = True
> > .Text = "^t" & "*" & "^t"
> > .Execute
> > myRange.Start = myRange.Start + 1
> > myRange.End = myRange.End - 1
> > myRange.Delete
> > End With
> > End Sub
> Thanks for the responses! But it sure sounds more complicated than it otta
> be!!?!! . (And to think that in WordPerfect all I had to do was hit one
> for "Select"!!) Let's assume for the moment - just for the sake of this
> discussion - that I don't do programming, that I am a newbie (note
> name) and I expect the Macro function to simply record keystrokes - then
> play them back on command. From the responses, may I conclude I'm outa
> on the delete-between-tabs routine, and that this is beyond the ability of
> Bill's programmers to build into this product?
> (In fact, I would use variations of the delete-between-tabs routine often,
> but each time it would use different from-to points. And I sure don't
> to have to write a program for every macro I use.)
> Bob

07-10-2005, 12:00 AM

If it performs like you expect then you are not missing anything :-)

All those swear words have a purpose. Klaus assumed, as did I, that
you wanted to keep the tabs and delete the text in between. Klaus also
assumed that you would want to limit the found range to a paragraph and
not delete the text say between the first and only tab in paragraph 1
and the first tab in paragraph 2.

Here is want the curse words are saying:

(1) Find a group consisting of a tab
[!13]@ find every possible following character except a paragraph mark
1 or more times
(2) Find a group consisting of a tab.

\1\2 in the Replace with tells word to remove all the muck it found and
replace it with the content of groups 1 and 2.

If you are up to some really foul literature, see fellow MVP Graham

Re: Select Tool in Macro ??