0

Greeting of the day everyone.

I am currently developing an Word 2016 adding using VSTO tools in VS2015. I hit a strange issue.

My requirement is to enable or disable PageBreakbefore in Word 2016 using a button. I manage to find the code is VB which is Selection.ParagraphFormat.PageBreakBefore = True which is simple True/ False thing.

Now, when I try to write the same code in C# .Net, which is Globals.ThisAddIn.Application.Selection.ParagraphFormat.PageBreakBefore = true It's giving an error.

The error is you can't convert int to bool. When we see the intellisense, it show that the value can be set to True or False. but if you see it's cast type, it's type of int . Intellisense Snapshot

Error

Any Help is appreciated.

Thanks for your time.

Regards Aman

Aman Dhally
  • 77
  • 2
  • 3
  • 10
  • and this is the MSDN page for the above property : https://msdn.microsoft.com/en-us/library/microsoft.office.interop.word._paragraphformat.pagebreakbefore.aspx – Aman Dhally Nov 04 '15 at 06:36

1 Answers1

0

It is resolved. Here is the solution .

To Enable PageBearkbefore

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

To Disable PageBreakbefore

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

Thanks. and I do hope that it will save someone else time :)

Regards Aman

Aman Dhally
  • 77
  • 2
  • 3
  • 10