Consulting

Results 1 to 9 of 9

Thread: Solved: Fix Pasted Name

  1. #1
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location

    Solved: Fix Pasted Name

    Suppose I copy a name that, unfortunately, could be in any of the following formats:

    TROY, ANNE M., M.D.

    TROY, ANNE M.

    What I'd like is, as soon as I paste, and my cursor is sitting at the end of the line, to hit a shortcut key that'll fix the name to (in the same order as above):

    ANNE TROY M., M.D.

    ANNE M. TROY

    Thanks tons, guys!

    http://www.utteraccess.com/forums/sh...&Number=656847
    ~Anne Troy

  2. #2
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    this is an interesting problem because of the various permutations. I expanded the problem a bit to include virtually any reasonable original format including the double suffix, e.g., Anne M. Troy, M.D., PhD

    My solution uses a few bits and pieces I had laying around plus some brute force code. It is not elegant, but it works. The attached zip contains both an xls test file and a Word test doc

  3. #3
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    MWE: The Word functions work very well. Although you may want to take a look at the xls file again; I receive errors. Double check your routine names and your auto-open procedure.

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I think this call for one of these RegExp pattern searchers, which is one of these things which I almost, but not quite, completely fail to understand.

  5. #5
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    LOL!! Function MWE_...

    Too cool. Can you add it to our KB, sir?? Please!!!!!!!!!
    ~Anne Troy

  6. #6
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Quote Originally Posted by firefytr
    MWE: The Word functions work very well. Although you may want to take a look at the xls file again; I receive errors. Double check your routine names and your auto-open procedure.
    You are absolutely right that the xls file was screwy. I have a VBA library of several hundred procs in my Personal.xls and this is referenced in every xls appl I develop. I keep forgetting (when I send something to others) to make sure that every proc referenced in that library is explicitly added to one of the appl code modules. Once I did that and unchecked the ref to Personal.xls, I noticed several problems:

    • duplicate code in both the worksheet code area and a general module
    • a call to a wrong proc
    • a call in Workbook_Open to a EvalCopy duration check proc
    • ref to Personal.xls was still checked
    Wow! that is enough goofs for today !!

    Whatever, the revised zip file should now have a working xls file.

    Quote Originally Posted by Dreamboat
    LOL!! Function MWE_...

    Too cool. Can you add it to our KB, sir?? Please!!!!!!!!!
    I have been thinking about what I might add. As per another reply to this thread, I have a fair number of MWE_... routines developed over the last few years. I try to develop code in logical, reusable pieces even if that sometimes means a little more passing of arguements. So many of these procs do quite simple things, but I never have to recode that function. Unfortunately, I tend to get something working and then make great plans to document, clean-up, etc.; and that does not happen as often as it should. I know that I am unique in this behaviour. Perhaps adding to the VBAX KB will be the incentive I need (and I would not mind a run at that quilt!)

  7. #7
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    It's not difficult to do once you know how.
    ~Anne Troy

  8. #8
    VBAX Newbie
    Joined
    Mar 2005
    Posts
    1
    Location

    Thank you!

    Just wanted to say thank you to every one that helped with this one. This solution works great!

    David Bazzelle

  9. #9
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Ah! I knew Dave would show up eventually. He was our original asker on this question. Thanks for letting us know, Dave!
    ~Anne Troy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •