I have the below code which is for modifying a textframe in a word document at runtime.
This is in a .NET Windows Forms app.
var oShapes = oWord.ActiveDocument.Shapes;
var titleShape = oShapes["Title"];
var myWord = new Microsoft.Office.Interop.Word.Application();
titleShape.Height = myWord.InchesToPoints(1.75F);
titleShape.Width = myWord.InchesToPoints(0.45F);
titleShape.RelativeHorizontalPosition = Microsoft.Office.Interop.Word.WdRelativeHorizontalPosition;
titleShape.RelativeVerticalPosition = Microsoft.Office.Interop.Word.WdRelativeVerticalPosition();
titleShape.Left = 4.35F;
titleShape.Top = 17.5F;
titleShape.TextFrame.WordWrap = 0;
titleShape.LockAnchor = 1;
var sTitle =string.Empty;
titleShape.TextFrame.TextRange.Text = DocumentType; // sTitle;
titleShape.TextFrame.AutoSize=-1;
Unfortunately I must have got it wrong because Microsoft.Office.Interop.Word.WdRelativeHorizontalPosition; is showing as an error in VS 2010 (and also on the line below.
What is the correct way to use word enumerated constants like that in c# through Office Interop?
I found it, I was calling the enumeration name, rather than the enumerated constant.
So Microsoft.Office.Interop.Word.WdRelativeHorizontalPosition
should be
Microsoft.Office.Interop.Word.WdRelativeHorizontalPosition.wdRelativeHorizontalPositionPage;
(plus I was using brackets thinking that was the problem)