I
ivanov.ivaylo
Hello,
I need a macro that will help me do some editor's checks in an MS Word
environment.
Can you help me write one because this is too complex for my
competence?
Specifications:
1. The macro must start from the cursor position and do a search (and
replace in certain cases).
2. The data that will feed the search field will be stored in a txt
file located in the same folder as the Word file. Each line contains
the search data, a separator "|" and a replace data after the
separator. If there is nothing after the separator, then no
replacement is needed and the macro stops for manual editing of the
text.
3. The macro will take the data from first line in the txt file, do a
search in the Word file for it and
3.1. if there is nothing after the separator "|", then the macro stops
where the search is positive (i.e. when there is a match in the Word
file for the data searched);
EXAMPLE:
, which| //A comma followed by the word "which". I'll check, for
example, if there is a need for a comma at this place. It doesn't
replace anything. The space after "|" is empty.
At this point, I'll do the editing if needed and hit a shortkey to
continue searching. The macro stops if there is a next match, I'll do
the editing, if needed and continue to the end.
3.2. if there is a further data after the separator "|", then the
macro replaces the search match with the value after the separator.
EXAMPLE:
([0-9]).([0-9])|\1,\2 //Find numbers containing a decimal point and
change them to numbers with a decimal comma
4. Then, the macro takes the data from the second line in the txt
file, do a search in the Word file for it.
5. The routine continues when there is no unsearched data left in the
text file, looping to the end of the document, then continuing from
the beginning, but always starting/resuming from the cursor position.
A sample txt file with a search data may look like the following:
, which| //A comma followed by the word "which". I'll check, for
example, if there is a need for a comma at this place. It doesn't
replace anything. The space after "|" is empty.
, that| //A comma followed by the word "that". I'll check, for
example, if there is a need for a comma at this place.It doesn't
replace anything. The space after "|" is empty.
<([0-9]@[/.-])([0-9]@[/.-])([0-9]@>)|MM/DD/YY(YY) //Find all numeric
dates from DD/MM/YY(YY) and changes them to format MM/DD/YY(YY)
([0-9]).([0-9])|\1,\2 //Find numbers containing a decimal point and
change them to numbers with a decimal comma
You can see that the list of search data may contain exact strings and
wildcard expressions. Is it possible for this macro or should it be
implemented in 2 macros - one for the normal search and another for
the wildcard (regex) search?
I need a macro that will help me do some editor's checks in an MS Word
environment.
Can you help me write one because this is too complex for my
competence?
Specifications:
1. The macro must start from the cursor position and do a search (and
replace in certain cases).
2. The data that will feed the search field will be stored in a txt
file located in the same folder as the Word file. Each line contains
the search data, a separator "|" and a replace data after the
separator. If there is nothing after the separator, then no
replacement is needed and the macro stops for manual editing of the
text.
3. The macro will take the data from first line in the txt file, do a
search in the Word file for it and
3.1. if there is nothing after the separator "|", then the macro stops
where the search is positive (i.e. when there is a match in the Word
file for the data searched);
EXAMPLE:
, which| //A comma followed by the word "which". I'll check, for
example, if there is a need for a comma at this place. It doesn't
replace anything. The space after "|" is empty.
At this point, I'll do the editing if needed and hit a shortkey to
continue searching. The macro stops if there is a next match, I'll do
the editing, if needed and continue to the end.
3.2. if there is a further data after the separator "|", then the
macro replaces the search match with the value after the separator.
EXAMPLE:
([0-9]).([0-9])|\1,\2 //Find numbers containing a decimal point and
change them to numbers with a decimal comma
4. Then, the macro takes the data from the second line in the txt
file, do a search in the Word file for it.
5. The routine continues when there is no unsearched data left in the
text file, looping to the end of the document, then continuing from
the beginning, but always starting/resuming from the cursor position.
A sample txt file with a search data may look like the following:
, which| //A comma followed by the word "which". I'll check, for
example, if there is a need for a comma at this place. It doesn't
replace anything. The space after "|" is empty.
, that| //A comma followed by the word "that". I'll check, for
example, if there is a need for a comma at this place.It doesn't
replace anything. The space after "|" is empty.
<([0-9]@[/.-])([0-9]@[/.-])([0-9]@>)|MM/DD/YY(YY) //Find all numeric
dates from DD/MM/YY(YY) and changes them to format MM/DD/YY(YY)
([0-9]).([0-9])|\1,\2 //Find numbers containing a decimal point and
change them to numbers with a decimal comma
You can see that the list of search data may contain exact strings and
wildcard expressions. Is it possible for this macro or should it be
implemented in 2 macros - one for the normal search and another for
the wildcard (regex) search?