How to search and replace multiple tabs

A

Adelle Gibson

I am trying to create a macro to search and replace one tab with two in a TOC. Problem is I currently have three tabs set in the paragraph and the one that I want to replace is the second tab. When I run the search and replace it changes the first tab to two. Any ideas on how to get around this problem.

Ex (current):
1.(tab)text(leader tab)digit

Ex (desired):
1.(tab)text(leader tab)(tab)digit


Submitted via EggHeadCafe - Software Developer Portal of Choice
ASP.NET: Hamburger, Yes! AJAX, "NOT!", Redux!
http://www.eggheadcafe.com/tutorial...9-934d-edb57ab852e3/aspnet-hamburger-yes.aspx
 
M

macropod

Hi Adelle,

For a TOC field, the 'correct' way is to edit the relevant TOC Styles. Otherwise the tabs are liable to reappear as soon as you
update the TOC field.

If the tabs are in the headings being picked up by the TOC, though, you'll need to either edit the headings themselves or change the
TOC Style to that the two tabs are effectively treated as one (eg by placing the corresponding tab stops as close together as
possible - which seems to be about 1.25pts apart).

--
Cheers
macropod
[Microsoft MVP - Word]


in message news:[email protected]...
 
A

Adelle Gibson

Thanks for your help.

After I generate a TOC I usually unlink it so that I can insert the section number and a hyphen before the page number. I can't use Word's built-in option for this since the client does not use auto numbering at all.

Here's an example of what I am trying to do.

1. Text.......... 1-1

Can someone help me write a macro that will (1) insert a tab, (2) pick up the first number on that line (i.e., 1), (3) add a hyphen before the page number.

If it helps, the blank space between the leader tab (set at 6.5) and 1-1 is actually a right-aligned tab set at 7.0.

I currently have to input this information manually throughout the entire TOC which, as you may have guessed, is a pain when it is 5 pages long.



macropod wrote:

Hi Adelle,For a TOC field, the 'correct' way is to edit the relevant TOC
23-Dec-09

Hi Adelle,

For a TOC field, the 'correct' way is to edit the relevant TOC Styles. Otherwise the tabs are liable to reappear as soon as you
update the TOC field.

If the tabs are in the headings being picked up by the TOC, though, you will need to either edit the headings themselves or change the
TOC Style to that the two tabs are effectively treated as one (eg by placing the corresponding tab stops as close together as
possible - which seems to be about 1.25pts apart).

--
Cheers
macropod
[Microsoft MVP - Word]

Previous Posts In This Thread:

How to search and replace multiple tabs
I am trying to create a macro to search and replace one tab with two in a TOC. Problem is I currently have three tabs set in the paragraph and the one that I want to replace is the second tab. When I run the search and replace it changes the first tab to two. Any ideas on how to get around this problem.

Ex (current):
1.(tab)text(leader tab)digit

Ex (desired):
1.(tab)text(leader tab)(tab)digit

Hi Adelle,For a TOC field, the 'correct' way is to edit the relevant TOC
Hi Adelle,

For a TOC field, the 'correct' way is to edit the relevant TOC Styles. Otherwise the tabs are liable to reappear as soon as you
update the TOC field.

If the tabs are in the headings being picked up by the TOC, though, you will need to either edit the headings themselves or change the
TOC Style to that the two tabs are effectively treated as one (eg by placing the corresponding tab stops as close together as
possible - which seems to be about 1.25pts apart).

--
Cheers
macropod
[Microsoft MVP - Word]


Submitted via EggHeadCafe - Software Developer Portal of Choice
How to display a Gravatar Image with 100 Percent Client Script Code
http://www.eggheadcafe.com/tutorial...c-b0877c10ecb4/how-to-display-a-gravatar.aspx
 
A

Adelle Gibson

Thanks for your help.

After I generate a TOC I usually unlink it so that I can insert the section number and a hyphen before the page number. I can't use Word's built-in option for this since the client does not use auto numbering at all.

Here's an example of what I am trying to do.

1. Text.......... 1-1

Can someone help me write a macro that will (1) insert a tab, (2) pick up the first number on that line (i.e., 1), (3) add a hyphen before the page number.

If it helps, the blank space between the leader tab (set at 6.5) and 1-1 is actually a right-aligned tab set at 7.0.

I currently have to input this information manually throughout the entire TOC which, as you may have guessed, is a pain when it is 5 pages long.



macropod wrote:

Hi Adelle,For a TOC field, the 'correct' way is to edit the relevant TOC
23-Dec-09

Hi Adelle

For a TOC field, the 'correct' way is to edit the relevant TOC Styles. Otherwise the tabs are liable to reappear as soon as yo
update the TOC field

If the tabs are in the headings being picked up by the TOC, though, you will need to either edit the headings themselves or change th
TOC Style to that the two tabs are effectively treated as one (eg by placing the corresponding tab stops as close together a
possible - which seems to be about 1.25pts apart)

-
Cheer
macropo
[Microsoft MVP - Word]

Previous Posts In This Thread:

How to search and replace multiple tabs
I am trying to create a macro to search and replace one tab with two in a TOC. Problem is I currently have three tabs set in the paragraph and the one that I want to replace is the second tab. When I run the search and replace it changes the first tab to two. Any ideas on how to get around this problem.

Ex (current):
1.(tab)text(leader tab)digit

Ex (desired):
1.(tab)text(leader tab)(tab)digit

Hi Adelle,For a TOC field, the 'correct' way is to edit the relevant TOC
Hi Adelle

For a TOC field, the 'correct' way is to edit the relevant TOC Styles. Otherwise the tabs are liable to reappear as soon as yo
update the TOC field

If the tabs are in the headings being picked up by the TOC, though, you will need to either edit the headings themselves or change th
TOC Style to that the two tabs are effectively treated as one (eg by placing the corresponding tab stops as close together a
possible - which seems to be about 1.25pts apart)

-
Cheer
macropo
[Microsoft MVP - Word]

Macro help!
Thanks for your help.

After I generate a TOC I usually unlink it so that I can insert the section number and a hyphen before the page number. I can't use Word's built-in option for this since the client does not use auto numbering at all.

Here's an example of what I am trying to do.

1. Text.......... 1-1

Can someone help me write a macro that will (1) insert a tab, (2) pick up the first number on that line (i.e., 1), (3) add a hyphen before the page number.

If it helps, the blank space between the leader tab (set at 6.5) and 1-1 is actually a right-aligned tab set at 7.0.

I currently have to input this information manually throughout the entire TOC which, as you may have guessed, is a pain when it is 5 pages long.


Submitted via EggHeadCafe - Software Developer Portal of Choice
Create Hidden SharePoint List for Site Owners
http://www.eggheadcafe.com/tutorial...60-917a85a41b08/create-hidden-sharepoint.aspx
 
D

Doug Robbins - Word MVP

A macro is probably not the correct thing to use. Rather, after unlinking
the table of contents, select the entries for each section in turn and then
use Edit>Replace with the Use wildcards box checked and search for

^t([0-9]{1,})

and replace it with

^t#-\1

where in place of the # you put the number of the section. For example for
Section 1, use

^t1-\1

A macro would not know where to change from 1- to 2- etc.

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.

Thanks for your help.

After I generate a TOC I usually unlink it so that I can insert the
section number and a hyphen before the page number. I can't use Word's
built-in option for this since the client does not use auto numbering at
all.

Here's an example of what I am trying to do.

1. Text.......... 1-1

Can someone help me write a macro that will (1) insert a tab, (2) pick up
the first number on that line (i.e., 1), (3) add a hyphen before the page
number.

If it helps, the blank space between the leader tab (set at 6.5) and 1-1
is actually a right-aligned tab set at 7.0.

I currently have to input this information manually throughout the entire
TOC which, as you may have guessed, is a pain when it is 5 pages long.



macropod wrote:

Hi Adelle,For a TOC field, the 'correct' way is to edit the relevant TOC
23-Dec-09

Hi Adelle,

For a TOC field, the 'correct' way is to edit the relevant TOC Styles.
Otherwise the tabs are liable to reappear as soon as you
update the TOC field.

If the tabs are in the headings being picked up by the TOC, though, you
will need to either edit the headings themselves or change the
TOC Style to that the two tabs are effectively treated as one (eg by
placing the corresponding tab stops as close together as
possible - which seems to be about 1.25pts apart).

--
Cheers
macropod
[Microsoft MVP - Word]

Previous Posts In This Thread:

How to search and replace multiple tabs
I am trying to create a macro to search and replace one tab with two in a
TOC. Problem is I currently have three tabs set in the paragraph and the
one that I want to replace is the second tab. When I run the search and
replace it changes the first tab to two. Any ideas on how to get around
this problem.

Ex (current):
1.(tab)text(leader tab)digit

Ex (desired):
1.(tab)text(leader tab)(tab)digit

Hi Adelle,For a TOC field, the 'correct' way is to edit the relevant TOC
Hi Adelle,

For a TOC field, the 'correct' way is to edit the relevant TOC Styles.
Otherwise the tabs are liable to reappear as soon as you
update the TOC field.

If the tabs are in the headings being picked up by the TOC, though, you
will need to either edit the headings themselves or change the
TOC Style to that the two tabs are effectively treated as one (eg by
placing the corresponding tab stops as close together as
possible - which seems to be about 1.25pts apart).

--
Cheers
macropod
[Microsoft MVP - Word]


Submitted via EggHeadCafe - Software Developer Portal of Choice
How to display a Gravatar Image with 100 Percent Client Script Code
http://www.eggheadcafe.com/tutorial...c-b0877c10ecb4/how-to-display-a-gravatar.aspx
 
D

Doug Robbins - Word MVP

Actually, if you select the whole of what was the table of contents and do a
wildcard search for

^t([0-9]{1,})^13([0-9]{1,}).

and replace it with

^t\2-\1^p\2.

it should modify all but the last page number in the table of contents.

For an explanation, see the Find and Replace using Wildcards article on the
following page of fellow MVP Graham Mayor's website:

http://www.gmayor.com/replace_using_wildcards.htm

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.

Thanks for your help.

After I generate a TOC I usually unlink it so that I can insert the
section number and a hyphen before the page number. I can't use Word's
built-in option for this since the client does not use auto numbering at
all.

Here's an example of what I am trying to do.

1. Text.......... 1-1

Can someone help me write a macro that will (1) insert a tab, (2) pick up
the first number on that line (i.e., 1), (3) add a hyphen before the page
number.

If it helps, the blank space between the leader tab (set at 6.5) and 1-1
is actually a right-aligned tab set at 7.0.

I currently have to input this information manually throughout the entire
TOC which, as you may have guessed, is a pain when it is 5 pages long.



macropod wrote:

Hi Adelle,For a TOC field, the 'correct' way is to edit the relevant TOC
23-Dec-09

Hi Adelle,

For a TOC field, the 'correct' way is to edit the relevant TOC Styles.
Otherwise the tabs are liable to reappear as soon as you
update the TOC field.

If the tabs are in the headings being picked up by the TOC, though, you
will need to either edit the headings themselves or change the
TOC Style to that the two tabs are effectively treated as one (eg by
placing the corresponding tab stops as close together as
possible - which seems to be about 1.25pts apart).

--
Cheers
macropod
[Microsoft MVP - Word]

Previous Posts In This Thread:

How to search and replace multiple tabs
I am trying to create a macro to search and replace one tab with two in a
TOC. Problem is I currently have three tabs set in the paragraph and the
one that I want to replace is the second tab. When I run the search and
replace it changes the first tab to two. Any ideas on how to get around
this problem.

Ex (current):
1.(tab)text(leader tab)digit

Ex (desired):
1.(tab)text(leader tab)(tab)digit

Hi Adelle,For a TOC field, the 'correct' way is to edit the relevant TOC
Hi Adelle,

For a TOC field, the 'correct' way is to edit the relevant TOC Styles.
Otherwise the tabs are liable to reappear as soon as you
update the TOC field.

If the tabs are in the headings being picked up by the TOC, though, you
will need to either edit the headings themselves or change the
TOC Style to that the two tabs are effectively treated as one (eg by
placing the corresponding tab stops as close together as
possible - which seems to be about 1.25pts apart).

--
Cheers
macropod
[Microsoft MVP - Word]

Macro help!
Thanks for your help.

After I generate a TOC I usually unlink it so that I can insert the
section number and a hyphen before the page number. I can't use Word's
built-in option for this since the client does not use auto numbering at
all.

Here's an example of what I am trying to do.

1. Text.......... 1-1

Can someone help me write a macro that will (1) insert a tab, (2) pick up
the first number on that line (i.e., 1), (3) add a hyphen before the page
number.

If it helps, the blank space between the leader tab (set at 6.5) and 1-1
is actually a right-aligned tab set at 7.0.

I currently have to input this information manually throughout the entire
TOC which, as you may have guessed, is a pain when it is 5 pages long.


Submitted via EggHeadCafe - Software Developer Portal of Choice
Create Hidden SharePoint List for Site Owners
http://www.eggheadcafe.com/tutorial...60-917a85a41b08/create-hidden-sharepoint.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top