HeyJim Posted November 25, 2005 Report Share Posted November 25, 2005 I've been running a macro in Word that does a control-f, inserts a comma, exits the FIND window when it encounters a comma and then TEXT TYPE's an ENTER. I'm thinking doing this through the clipboard would be lots faster since it's currently taking us over 30 minutes to do this in Word even using REPEAT 1000's of times in just one extremely large document. (I'm converting documents from 100+ pages of text to an extremely long list.) I've been playing with variables and repeats because it should be pretty simple but no dice so far. Could someone please post the couple of lines of code necessary to replace all of the commas in clipboard with ENTERS and then spit the result out of clipboard on to a blank page I'd have open? Thanks. Quote Link to comment Share on other sites More sharing options...
Cory Posted November 25, 2005 Report Share Posted November 25, 2005 You need to fist generate the CRLF as a variable. Click here to see a small subroutine I use all the tiem for this purpose. It does both but the important thing to understand is that an enter is actually two characters, carrige return and line feed. <REM2:Set CR><ASCIIC:95:1:13><ASCIIC:96:1:10><TVAR2:95:01:%T95%%T96%><REM2:Set CR><CLIPT><TVAR2:01:03:><TMVAR2:21:01:01:000:000:,%T95%><TEXTTYPE:%T1%> Might look like this in the script. // Set CRVariable Set %T95% to ASCII Char of 13 Variable Set %T96% to ASCII Char of 10 Variable Set String %T95% "%T95%%T96%" // Set CR Clipboard Cut Variable Set String %T1% from Clipboard Replace "," with "%T95%" in %T1% Text Type: %T1% As an asside you might consider modifing the file directly. Read each line in directly, do the substitution and write it back out to a new file. This would be a lot faster. Quote Link to comment Share on other sites More sharing options...
joe Posted November 26, 2005 Report Share Posted November 26, 2005 Hello HeyJim! Another option (something I've done in the past) is to use Find and Replace (Ctrl+H) instead of just Find. See the attached picture. By setting the Search field to "All", every instance of a comma will be changed to a CR/LF at once in the document. Quote Link to comment Share on other sites More sharing options...
HeyJim Posted November 26, 2005 Author Report Share Posted November 26, 2005 Thanks, Cory, Joe. I used both suggestions. Not that I had to do that. I had to remove the clipboard cut command from the macro and then it worked perfectly. Had me scratching my head wondering for a couple of minutes but no big deal. As I suspected and everyone else on the board probably knew it was WAY faster than the way I had been using. Then I couldn't help but try your way, Joe. Didn't know I could use a ^p for the replace. Also found out it's case sensitive. I've learned from both of you. Thanks again. Jim Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.