Selection.EndKey not working in 2010
I've recently migrated some XP templates to 2010 and am now having problems with some of my VBA that should be inserting AutoText (which consists of some text and a table) at the end of the document. The code is:
Selection.EndKey Unit:=wdStory
ActiveDocument.AttachedTemplate.AutoTextEntries("m yStandardText") _
.Insert Where:=Selection.Range, RichText:=True
When the macro runs normally it's as if the Selection.EndKey line is being completely ignored because my AutoText ends up wherever the cursor happens to be.
The strange thing is that if I put a breakpoint anywhere before this line and then once it's stopped, press the run button/press F5, all runs as it should.
This almost feels like some kind of "refresh" issue, as if the code is just running too quickly and performing the insertion of the AutoText before the cursor gets the chance to move. I've tried putting an ActiveDocument.Repaginate before the above code but that doesn't help.
Any thoughts mightily appreciated...
|