Thanks
i've changed your code as follow :
private static void FindAndReplaceLargeContent2(Microsoft.Office.Interop.Word.Application wordApp, object strSearch, object strReplace)
{
object missing = System.Reflection.Missing.Value;
object foward = true;
Microsoft.Office.Interop.Word.WdFindWrap wrapFind = Microsoft.Office.Interop.Word.WdFindWrap.wdFindStop;
object wrapExecute = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;
List<string> subs = new List<string>();
int counter = 0;
while (counter <= strSearch.ToString().Length)
{
if (strSearch.ToString().Length < counter + 250)
{
subs.Add(strSearch.ToString().Substring(counter, strSearch.ToString().Length - counter));
}
else
{
subs.Add(strSearch.ToString().Substring(counter, 250) + "#r#");
}
counter += 250;
}
wordApp.Selection.Range.Find.ClearFormatting();
wordApp.Selection.Range.Find.Replacement.ClearFormatting();
wordApp.Selection.Range.Find.Text = strSearch.ToString();
wordApp.Selection.Range.Find.Wrap = wrapFind;
wordApp.Selection.Range.Find.Replacement.Text = subs[0];
wordApp.Selection.Range.Find.Execute(ref strSearch, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref strReplace, ref wrapExecute, ref missing, ref missing, ref missing,
ref missing);
wordApp.Selection.Range.Find.Text = "#r#";
for (int i = 1; i < subs.Count; i++)
{
wordApp.Selection.Range.Find.Replacement.Text = subs[i];
wordApp.Selection.Range.Find.Execute(ref strSearch, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref strReplace, ref wrapExecute, ref missing, ref missing, ref missing,
ref missing);
}
}
but still i'm facing the same problem!!!!
http://www.codeproject.com/KB/codegen/DatabaseHelper.aspx
No comments:
Post a Comment