V
vincent
I want to select all the text in the documet and change it color before I
save the document.
How to do that?
Thank you for your replying.
WORD._Application word = null;
WORD._Document document = null;
Object fileName = (Object)tagetFileName;
try
{
word = new WORD.Application();
document = word.Documents.Add(
/* ref object Template */ ref word2jpgTemplate,
/* ref object NewTemplate */ ref missing,
/* ref object DocumentType */ ref missing,
/* ref object Visible */ ref missing);
//document.PageSetup.PageHeight = 999;
//document.PageSetup.PageWidth = 999;
//document.PageSetup.BottomMargin = 0;
//document.PageSetup.TopMargin = 0;
//document.PageSetup.LeftMargin = 0;
//document.PageSetup.RightMargin = 0;
document.SaveAs(
/* ref object FileName */ ref fileName,
/* ref object FileFormat */ ref fileFormat,
/* ref object LockComments */ ref missing,
/* ref object Password */ ref missing,
/* ref object AddToRecentFiles */ ref missing,
/* ref object WritePassword */ ref missing,
/* ref object ReadOnlyRecommended */ ref missing,
/* ref object EmbedTrueTypeFonts */ ref missing,
/* ref object SaveNativePictureFormat */ ref missing,
/* ref object SaveFormsData */ ref missing,
/* ref object SaveAsAOCELetter */ ref missing,
/* ref object Encoding */ ref missing,
/* ref object InsertLineBreaks */ ref missing,
/* ref object AllowSubstitutions */ ref missing,
/* ref object LineEncoding */ ref missing,
/* ref object AddBiDiMarks */ ref missing);
}
catch (COMException exception)
{
Console.WriteLine(exception.ToString());
}
finally
{
if (document != null)
{
document.Close(
/* ref object SaveChanges */ ref missing,
/* ref object OriginalFormat */ ref missing,
/* ref object RouteDocument */ ref missing);
document = null;
}
if (word != null)
{
word.Quit(
/* ref object SaveChanges */ ref missing,
/* ref object OriginalFormat */ ref missing,
/* ref object RouteDocument */ ref missing);
word = null;
}
}
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
save the document.
How to do that?
Thank you for your replying.
WORD._Application word = null;
WORD._Document document = null;
Object fileName = (Object)tagetFileName;
try
{
word = new WORD.Application();
document = word.Documents.Add(
/* ref object Template */ ref word2jpgTemplate,
/* ref object NewTemplate */ ref missing,
/* ref object DocumentType */ ref missing,
/* ref object Visible */ ref missing);
//document.PageSetup.PageHeight = 999;
//document.PageSetup.PageWidth = 999;
//document.PageSetup.BottomMargin = 0;
//document.PageSetup.TopMargin = 0;
//document.PageSetup.LeftMargin = 0;
//document.PageSetup.RightMargin = 0;
document.SaveAs(
/* ref object FileName */ ref fileName,
/* ref object FileFormat */ ref fileFormat,
/* ref object LockComments */ ref missing,
/* ref object Password */ ref missing,
/* ref object AddToRecentFiles */ ref missing,
/* ref object WritePassword */ ref missing,
/* ref object ReadOnlyRecommended */ ref missing,
/* ref object EmbedTrueTypeFonts */ ref missing,
/* ref object SaveNativePictureFormat */ ref missing,
/* ref object SaveFormsData */ ref missing,
/* ref object SaveAsAOCELetter */ ref missing,
/* ref object Encoding */ ref missing,
/* ref object InsertLineBreaks */ ref missing,
/* ref object AllowSubstitutions */ ref missing,
/* ref object LineEncoding */ ref missing,
/* ref object AddBiDiMarks */ ref missing);
}
catch (COMException exception)
{
Console.WriteLine(exception.ToString());
}
finally
{
if (document != null)
{
document.Close(
/* ref object SaveChanges */ ref missing,
/* ref object OriginalFormat */ ref missing,
/* ref object RouteDocument */ ref missing);
document = null;
}
if (word != null)
{
word.Quit(
/* ref object SaveChanges */ ref missing,
/* ref object OriginalFormat */ ref missing,
/* ref object RouteDocument */ ref missing);
word = null;
}
}
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();