简体   繁体   English

Interop Word 中的页列

[英]Page columns in Interop Word

Does any one know how to split a word document into columns using c#, At a specific point.有谁知道如何使用 c# 将 word 文档拆分为列,在特定点。

doc.Sections.PageSetup.TextColumns.SetCount(2);

The above code does the complete document, Not just from a specific point上面的代码做完整的文档,不只是从一个特定的点

Assuming that you have located or navigated to the specific point , 假设您已定位或导航到特定点

Selection.InsertBreak Type:=wdSectionBreakContinuous

is the VBA code that would insert a (continuous) section break. 是将插入(连续)分节符的VBA代码。

(From C# Selection is preceded by the reference to the Word Application.) (从C# Selection之前,先引用Word应用程序。)

Then 然后

doc.Sections(1).PageSetup.TextColumns.SetCount(2);

would apply the columns to section one. 将列应用于第一节。

I found another way to set columns from a specific point to the end of doc.我找到了另一种将列从特定点设置到文档末尾的方法。

object oMissing = Missing.Value;
object oEndOfDoc = "\\endofdoc";
//Start Word and create a new document.
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,ref oMissing, ref oMissing);

//here you insert your paragraphs...

oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range.InsertBreak(Word.WdBreakType.wdSectionBreakContinuous);
oDoc.Sections[2].PageSetup.TextColumns.SetCount(2);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM