Alright, not sure if I'm in the right place here, but you guys have been helpful to me in the past. I am currently writing an app in C# that is generating reports in Word. I'm using VBA code to guide me as the code is 75% similar.
I need to know how to go about deselecting a table so when I insert text, the table doesn't get written over. Here is the chunk of VBA I'm using as reference to do this:
Question is: 1) Is there a better way to take out the borders without selecting the table?
-and-
2) If not, how do I go about deselecting the table?
An answer in VBA is fine, I can convert it to C#.
Thanks!
--Brad
PS: Here is the C# code I'm using in case anyone is interested. In it, I am able to put text in the cell I want but the table remains selected and highlighted.
I need to know how to go about deselecting a table so when I insert text, the table doesn't get written over. Here is the chunk of VBA I'm using as reference to do this:
Code:
Selection.Tables(1).Select
With Selection.Tables(1)
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With
Selection.TypeText Text:="test text"
Question is: 1) Is there a better way to take out the borders without selecting the table?
-and-
2) If not, how do I go about deselecting the table?
An answer in VBA is fine, I can convert it to C#.
Thanks!
--Brad
PS: Here is the C# code I'm using in case anyone is interested. In it, I am able to put text in the cell I want but the table remains selected and highlighted.
Code:
myWord.Selection.Tables[1].Select();
myWord.Selection.Tables[1].Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleNone;
myWord.Selection.Tables[1].Borders.InsideLineStyle = Word.WdLineStyle.wdLineStyleNone;
myWord.Selection.MoveLeft(ref wdCharacter, ref Count, ref wdExtend);
myWord.Selection.MoveDown(ref wdLine, ref Count, ref wdExtend);
myWord.Selection.Tables[1].Cell(2,1).Range.Text = "This is a cell";