Hi Pedro
Technically, you should address questions concerning any Office object model to the appropriate group listed in the "Please Read First" posting at the top of this forum
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=174275&SiteID=1
This forum is dedicated to discussions concerning the VSTO technology, which it appears you aren't using.
I can tell you that you ought to be working with RANGES in Word, not with the Selection object. Ranges give you more flexibility, they're faster and the screen won't "flash" as much since Word won't be mimicking user actions. When you have a Range, you have an object you can store in memory and manipulate at any time. Your multiple lines of code can be condensed into one command, and afterwards the Range object can be formatted "at leisure". For example:
Word.Range rng = oDoc.Content; rng.Text = DateTime.Now.ToLongDateString() + "\n\n" + title + " " + clientName +" "+clientSurname + "\n" + clientAddress + "\n" + clientTown + " " + clientPostalCode;
rng.Font.Name = "Arial"; rng.Font.Size = 11;
//Position the range to just after the current range content object directEnd = WdCollapseDirection.wdCollapseEnd; rng.Collapse(ref directEnd);
rng.Text = "\n\nDear " + clientName + " " + clientSurname
rng.Font.Name = "Bookman Antiqua"; rng.Font.Size = 12;
-- Cindy Meister (Word MVP) |