Find Result Copy And Paste


J

jic

Hi.

I am doing a search on two documents for highlighted words or
sentences. The both finds commands are working find, but the copy and
paste are adding an extra newline.

var ad = word.Documents.Open(file);
xf = word.ActiveDocument; // Extract From doc
xfRange = xf.Range(0,0);
//xSel = word.Selection;
var doc = word.Documents.Open(tfile);// the translated file with
translated strings
as = word.ActiveDocument;
var myRange = doc.Range(0,0);

xfRange.Find.ClearFormatting();
xfRange.Find.Highlight = true;
xfRange.Find.Replacement.ClearFormatting();
xfRange.Find.Text = "";
xfRange.Find.Forward = true;
xfRange.Find.Wrap = wdFindStop; // stop after end of document
xfRange.Find.Format = true;
xfRange.Find.MatchCase = false;
xfRange.Find.MatchWholeWord = false;
xfRange.Find.MatchKashida = false;
xfRange.Find.MatchDiacritics = false;
xfRange.Find.MatchAlefHamza = false;
xfRange.Find.MatchControl = false;
xfRange.Find.MatchByte = false;
xfRange.Find.CorrectHangulEndings = false;
xfRange.Find.MatchWildcards = false;
xfRange.Find.MatchSoundsLike = false;
xfRange.Find.MatchAllWordForms = false;
xfRange.Find.Execute();

myRange.Find.ClearFormatting();
myRange.Find.Highlight = true;
myRange.Find.Replacement.ClearFormatting();
myRange.Find.Text = "";
myRange.Find.Forward = true;
myRange.Find.Wrap = wdFindStop; // stop after end of document
myRange.Find.Format = true;
myRange.Find.MatchCase = false;
myRange.Find.MatchWholeWord = false;
myRange.Find.MatchKashida = false;
myRange.Find.MatchDiacritics = false;
myRange.Find.MatchAlefHamza = false;
myRange.Find.MatchControl = false;
myRange.Find.MatchByte = false;
myRange.Find.CorrectHangulEndings = false;
myRange.Find.MatchWildcards = false;
myRange.Find.MatchSoundsLike = false;
myRange.Find.MatchAllWordForms = false;
myRange.Find.Execute();
while (myRange.Find.Found == true)
{
if (myRange.Find.Parent.HighlightColorIndex == wdYellow)
{
if (xfRange.Find.Found == true)
{

xfRange.Find.Parent.Copy();
myRange.Find.Parent.Paste();

xfRange.Find.Execute();
}
else
{
w.Echo("Oh boy! Problem on the land...");
w.Quit();
}
}
myRange.Find.Execute();
}
....
.....

This works like a charm with the exception that the Pasted string has
a newline and it breaks the sentence. For example, the original
sentence is,

Hi there. I am here and you are there.

Let's say that here is highlighted, after the paste, the sentence
becomes,

Hi there. I am here
and you are there.

I am using the same document as a test. Any help would be greatly
appreciated.

thanks,

jic
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top