Chnage style in an existing document

Hi,

how can I apply existing styles to some text in an existing document? Example:

object obj1 = Word.WdUnits.wdLine;
object obj2 = Word.WdMovementType.wdExtend;
selection.EndKey(ref obj1, ref obj2); // select the current line
selection.set_Style("Bissantz Heading 2"); // apply some user specific style

Anyway, I am missing the "Selection" object which is a crucial object when formatting DOC-files using MS Office InteropAssemblies. I still did not find the corresponding object of DocIO.

Thanks & best regards
Christian

1 Reply

AJ Ajish Syncfusion Team July 3, 2007 09:04 PM UTC

Hi Christian,

Thank you for your interest in Essential DocIO.

Essential DocIO supports creation of custom styles that can apply a whole group of formats in one simple task. This sample demonstrates how custom styles can be created and applied using Essential DocIO.

Here is a code snippet to create and apply custom styles.

// Create Paragraph styles
IParagraphStyle style = document.AddParagraphStyle ( "MyStyle");
style.CharacterFormat.FontName = "Bitstream VeraSerif";
style.CharacterFormat.FontSize = 10f;

// Applying style to the current paragraph.
paragraph.ApplyStyle ( "MyStyle" );

A sample demonstrating support for StylesAnd Formatting is available along with our install and it can be found at the following path

C:\Documents and Settings\{user}\My Documents\Syncfusion\EssentialStudio\5.1.1.0\Windows\DocIO.Windows\Samples\2.0\Document Formatting\StylesAndFormatting\cs

Kindly take a look and let us know if you have any other questions.

Regards,
Ajish.


Loader.
Up arrow icon