(Edited by jscher2000 on 05-Feb-08 14:02. Moved to a new thread and retitled.)
At the office, I can’t create a new post, so I’m replying to one of my older posts. I’m now using Word 2003. I keep hyphenation on by default. I have a macro that supposedly turns off hyphenation, then copies the selection, and then turns hyphenation back on (code is below). I want to do this because sometimes I past selections from Word into other applications (e.g., something running in Internet Explorer) and don’t want the hyphens to appear in the pasted text. I thought my code below worked in versions prior to Word 2003, but it doesn’t seem to be working now. Whenever I paste the selection, there is a hyphen in the middle of some words.
ActiveDocument.AutoHyphenation = False ‘Turns off hyphenation before copy
Selection.Copy
ActiveDocument.AutoHyphenation = True
I thought maybe the problem was that the macro was moving too fast and grabbing the selection before hyphenation could be turned off in the selection. If I step thru the macro using F8 in the VB Editor, it works fine!! However, when it runs at regular speed, it doesn’t!!
I tried adding ScreenUpdate = Refresh (or something like that) after turning hyphenation off. That didn’t work. I tried adding a for loop to try to pause the macro a bit, but that didn’t work either (I might not have created a long enough loop, but who knows — I only use x = 1 to 25).
The following works, but doesn’t always give me the results I want when I paste, so I’d like to get the hyphenation on/off method to work.
Selection.NoProofing = True ‘Hyphenation not working, but NoProofing works
Selection.Copy
Selection.NoProofing = False
I thought of the above after searching for hyphenation macros here and running across my original post about the single word no hyphenation macro.
Anyway, the problem with the noproofing method is that I’m copying bulleted lists from a table cell, and the last item does not have a hard return/paragraph marker (just the end of cell/row marker). If I use my hyphenation code, and select the period before the end of the bullet, and paste into my other application, the bullets appear as little dots. However, if I use the noproofing method, the last bullet does not appear (because I’m not able to select a final hard return/paragraph mark at the end).
Any suggestions on getting the hyphenation method to work? Is there some way to force a redraw of the screen that might do what I want? I thought maybe there was a way to turn off the selection, turn off hyphenation, then turn the same selection back on, but I couldn’t quite figure that out either. I can’t seem to find something to re-select. I suspect it exists; I just can’t find it.
Thanks for the help.
-Rich