Setting line spacing for Word 2007 in the Neutral Path plan

I'm having trouble adjusting line spacing in Word 2007. Word 2007 by default has double spacing or extra space between lines. Previously, I have always successfully used something similar (In C #):

//No spacing when using Word version > 2003
//Word 2003 = "11.0"
//Word 2007 = "12.0"
Word.Application appVersion = new Word.Application();
string sVersion = appVersion.Version.ToString();
if (sVersion != "11.0")
{
    object noSpacingStyle = "No Spacing";
    oWord.ActiveWindow.Selection.set_Style(ref noSpacingStyle);
}

But this breaks down when trying to apply it in some regional / cultural conditions, such as Italian and German. I believe this is because “No Interval” should be in the target language, and not on the hard drive, as in English. So, I'm trying to find a way to apply this same change in a more portable way.

I tried sifting through various enumerations, such as "WdBuiltinStyle", but I can't seem to find one that does the same as "No Interval".

Does anyone know how to do this?

+3
source share
2 answers

How about using

Selection.ParagraphFormat.LineSpacingRule = WdLineSpacing.wdLineSpaceSingle;

In your code, the line spacing is not specified; it sets the style that has a specific spacing to it.

A quote from a person asked how they solved it, since this is an accepted answer:

As Joey suggested, the solution is to use Word's built-in styles. I resolved this by applying the following to my Word._Application Object:

oWord.ActiveWindow.Selection.ParagraphFormat.LineSpacingRule = Word.WdLineSpacing.wdLineSpaceSingle;
oWord.ActiveWindow.Selection.ParagraphFormat.SpaceAfter = 0.0F;
+5
source

, , Word, . , Word._Application:

oWord.ActiveWindow.Selection.ParagraphFormat.LineSpacingRule = Word.WdLineSpacing.wdLineSpaceSingle;
oWord.ActiveWindow.Selection.ParagraphFormat.SpaceAfter = 0.0F;
+1

Source: https://habr.com/ru/post/1785036/


All Articles