以文化中立的方式设置Word 2007的行间距(Setting Line Spacing for Word 2007, in Culturally Neutral Way)

编程入门 行业动态 更新时间:2024-10-11 11:22:24
以文化中立的方式设置Word 2007的行间距(Setting Line Spacing for Word 2007, in Culturally Neutral Way)

我在Word 2007中设置行间距时遇到问题.Word 2007默认为双倍间距或行之间有额外的空格。 以前,我总是使用类似的东西成功(在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); }

但是,当试图在一些地区/文化环境中应用它时,例如意大利语和德语,这种情况就会破裂。 我相信这是因为“No Spacing”需要使用目标语言,而不是硬编码为英语。 所以,我试图想出一种以更便携的方式应用这种相同变化的方法。

我已经尝试过各种枚举,例如“WdBuiltinStyle”,但似乎找不到一个完成与“无间距”相同的东西。

这里有谁知道如何做到这一点?

I am having trouble setting the line spacing in Word 2007. Word 2007 defaults to double spacing or to having extra space between lines. Previously, I have always used something similar to this with success (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 is breaking when trying to apply it under some regional/cultural settings, such as Italian and German. I believe this is because "No Spacing" needs to be in the target language, instead of hardcoded as English. So, I am trying to figure out a way to apply this same change in a more portable way.

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

Does anyone here know how to accomplish this?

最满意答案

怎么样使用

Selection.ParagraphFormat.LineSpacingRule = WdLineSpacing.wdLineSpaceSingle;

您的代码未设置行间距,它会设置应用了特定行间距的样式。

引用该人询问他们是如何解决的,因为这是公认的答案:

正如Joey所说,解决方案是使用Word的内置样式。 我通过将以下内容应用于我的Word._Application对象解决了这个问题:

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

What about using

Selection.ParagraphFormat.LineSpacingRule = WdLineSpacing.wdLineSpaceSingle;

Your code does not set the line spacing, it sets a style that has certain line spacing applied to it.

Quoting from the person asked how they solved it, since this is the 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;

更多推荐

本文发布于:2023-08-07 18:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465337.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:行间   方式   文化   Word   Culturally

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!