cotton9
asked on
SIMPLE - Use VBA to change hyphenated "list" to sequential numbers
Hello,
I'm working with medical office management software that generates reports as a Word doc. One of its annoyances is that It lists the treatments at the bottom of the report in a hyphenated list (although Word doesn't recognize it as an actual list - which is ok.)
I want to use VBA to change the hyphens to sequential numbers followed by a ")" symbol.
For example...
TREATMENT:
- This is treatment one.
- This is treatment two.
- This is an optional third treatment, etc.
turns into...
TREATMENT:
1) This is treatment one.
2) This is treatment two.
3) This is an optional third treatment, etc.
I'm guessing one of you VBA geniuses can whip up this code in less time that it took me to type out the problem. I'd really appreciate the help. Thanks!
I'm working with medical office management software that generates reports as a Word doc. One of its annoyances is that It lists the treatments at the bottom of the report in a hyphenated list (although Word doesn't recognize it as an actual list - which is ok.)
I want to use VBA to change the hyphens to sequential numbers followed by a ")" symbol.
For example...
TREATMENT:
- This is treatment one.
- This is treatment two.
- This is an optional third treatment, etc.
turns into...
TREATMENT:
1) This is treatment one.
2) This is treatment two.
3) This is an optional third treatment, etc.
I'm guessing one of you VBA geniuses can whip up this code in less time that it took me to type out the problem. I'd really appreciate the help. Thanks!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Both of the above solutions result in changing all hyphens found within the document, not just those found in the "TREATMENT:" section.
I thought I might be able to fix it myself by finding "TREATMENT:" first to set the cursor location (per Kimputer's solution) and then changing wdFindContinue to wdFindStop within the loop that finds/replaces the hyphens. But that resulted in not finding any hyphens at all.
However, if I physically place the cursor at the word "TREATMENT:" instead of finding it with VBA, using wdFindStop works w/ Rgonzo1971's code.
Ideas?
I thought I might be able to fix it myself by finding "TREATMENT:" first to set the cursor location (per Kimputer's solution) and then changing wdFindContinue to wdFindStop within the loop that finds/replaces the hyphens. But that resulted in not finding any hyphens at all.
However, if I physically place the cursor at the word "TREATMENT:" instead of finding it with VBA, using wdFindStop works w/ Rgonzo1971's code.
Ideas?
pls try
Open in new window
Regards