Hi James,
I am writing a word automation in c#, however, when I merge 2 word
documents(copy and paste) it actually creates a new line after paste.
Is it possible to remove the next line (and how) or there is a proper
way to copy and paste?
Hmmm. Emulating the user's actions (copy/paste, then backspace) isn't
really the most desirable, efficient or reliable method to automate
Word. If you're going to be doing a lot of this, then you need to learn
how to use Word's object model, otherwise you're in for a lot of
frustration and, possibly, angry users.
1. Did you test InsertFile before deciding on Copy/Paste? Or, if you're
dealing with two files that are already open on the UI, the
Range.FormattedText property? Either of these would be preferable to
copy/paste in most circumstances.
2. It would be more correct to delete a RANGE of characters, rather
than use "Backspace". There's really no way to guarantee that the
cursor is going to be where it is when you're testing. Much better
would be to ascertain the range (is this the end of the document, for
example?) and remove that.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail
