2015-11-04 76 views
0

每個人的問候。使用VSTO插件上的C#+ .Net在Word 2016中啓用/禁用「PageBreakBefore」。

我目前正在開發在VS2015中使用VSTO工具添加Word 2016。我遇到了一個奇怪的問題。

我的要求是在Word 2016中使用按鈕啓用或禁用PageBreakbefore。我設法找到代碼是VB,它是Selection.ParagraphFormat.PageBreakBefore = True這是簡單的真/假事。

現在,當我嘗試在C#.Net中編寫相同的代碼時,它是Globals.ThisAddIn.Application.Selection.ParagraphFormat.PageBreakBefore = true它提供了一個錯誤。

錯誤是你不能將INT轉換爲BOOL。當我們看到intellisense時,顯示值可以設置爲TrueFalse。但如果你看到它是cast類型的話,它的類型是intIntellisense Snapshot

Error

任何幫助表示讚賞。

謝謝你的時間。

問候 阿曼

+0

這是上述財產的MSDN頁:https://msdn.microsoft.com/en-us/library/ microsoft.office.interop.word._paragraphformat.pagebreakbefore.aspx –

回答

0

它解決。這是解決方案。

啓用PageBearkbefore

Globals.ThisAddIn.Application.Selection.ParagraphFormat.PageBreakBefore = -1; 

禁用PageBreakbefore

Globals.ThisAddIn.Application.Selection.ParagraphFormat.PageBreakBefore = 0; 

感謝。我也希望這將節省別人的時間:)

問候 阿曼