Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert numeric to alphanumeric 3

Status
Not open for further replies.

acl03

MIS
Jun 13, 2005
1,077
US
I have a document with a lot of numbers in numeric form. I want to change them all to alphanumeric ("fifteen", "twenty", etc). Any easy way to do that in VBS?

Thanks,
Andrew

[smarty] Hard work often pays off over time, but procrastination pays off right now!
 
I have a document with a lot of numbers
If it's a Word document, you could cut & paste the number into a formula field with the CardText or DollarText switch. For example, '12345' gets pasted into a formula field coded as {=12345 \* CardText}, where field brace pairs (ie '{ }') are created via Ctrl-F9 (or the vba equivalent - .Fields Add).


Cheers
[MS MVP - Word]
 
Great, thanks. One of these should work fine.

Thanks,
Andrew

[smarty] Hard work often pays off over time, but procrastination pays off right now!
 
I got this working. Sort of - part of this program uses regex to do the replacement. It's working fine, but part of my match inculudes a double quote ("). I cannot figure out how to match on double quote with regex. I've tried everything I can think of.

How is it done?



Thanks,
Andrew

[smarty] Hard work often pays off over time, but procrastination pays off right now!
 
Why not post the code where you're stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sure, it's this line. My temporary workaround is to do a search and replace in the document and replace all " with %.

Ideally, I'd want all the percent signs to be double-quotes, but I don't know how to match on it. Normally a backslash before the special character is used as an escape char, but it's not working for the quote. I thought maybe I'd need \"" but that didn't work either.

re.Pattern = "(.*%#i?-?)([0-9]{3,3})(%.*)"

Thanks,
Andrew

[smarty] Hard work often pays off over time, but procrastination pays off right now!
 
What about this ?
re.Pattern = "(.*""#i?-?)([0-9]{3,3})("".*)"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV....I KNOW i tried that, and I swear it did not work last time! It sure did this time.

I guess in all my frustration I forgot the most logical choice. Thanks :)

Thanks,
Andrew

[smarty] Hard work often pays off over time, but procrastination pays off right now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top