Set Word 2010 document margins from C#

RCam picture RCam · Jan 17, 2012 · Viewed 9.3k times · Source

I want to set the margins on a Word document I'm creating using automation from code in C#.

I've started the process using ActiveDocument.TopMargin = but I cannot find the C# code similar to the vb Word.InchesToPoint(.5) Any help would be greatly appreciated

Answer

RCam picture RCam · Jan 18, 2012

Sometimes the simplest way works. This line of code solved the problem

oWord.ActiveDocument.PageSetup.TopMargin = (float)50;