I am trying to set the print margins in a Word Doc I am printing from my c# application but I am having trouble accessing the methods that I need to call (based on what they are in MS Word VBA)
In VBA the code looks like this:
Options.printBackground = False
With ActiveDocument.PageSetup
.TopMargin = CentimetersToPoints(0.61)
.BottomMargin = CentimetersToPoints(0.43)
.LeftMargin = CentimetersToPoints(1.27)
.RightMargin = CentimetersToPoints(0.43)
.Gutter = CentimetersToPoints(0)
End With
Here is my c# code
oWordDoc.PageSetup.TopMargin = Microsoft.Office.Interop.Word.Application.CentimetersToPoints(float.Parse ("0.61")) ;
The error I am getting is:
An object reference is required for the non-static field, method, or property 'Microsoft.Office.Interop.Word._Application.CentimetersToPoints(float)'
I have tried several varaiations after searching the VS 2010 Object Browser for CentimetersToPoints
The available interfaces in the Object Browser are:
- Microsoft.Office.Interop.Word._Application.CentimetersToPoints(float)
- Microsoft.Office.Interop.Word.ApplicationClass.CentimetersToPoints(float)
- Microsoft.Office.Interop.Word._Global.CentimetersToPoints(float)
- Microsoft.Office.Interop.Word.GlobalClass.CentimetersToPoints(float)
how can I access methods like this?
thanks