Hi,
I am pretty new to vb.net and I am having a bit of trouble placing a table in Word through automation.
I am adding a table at a Bookmark. The bookmark is outside the margins of the page, but when the table gets placed, it starts at the margin, rather than where the bookmark was. I have tried several ways of moving it, and the only way that did anything of value was changing the page margins for the entire document, which is not what I want to do...
Here is the code that I am using at the moment.
Dim oTable1 As Word.Table
oWord.Visible = True
'Insert a 2 x 6 table and fill it with specific data
oTable1 = oDoc.Tables.Add(oDoc.Bookmarks.Item("installation").Range, 2, 6)
'Create Columns Code,description,unit,recommended retail,disc,distribution
With oTable1
.Range.ParagraphFormat.SpaceAfter = 6
.Range.ParagraphFormat.LeftIndent = 5
.Columns(1).PreferredWidthType = Word.WdPreferredWidthType.wdPreferredWidthPercent
.Columns(1).PreferredWidth = 13.3
.Columns(2).PreferredWidth = 39.8
.Columns(3).PreferredWidth = 6.6
.Columns(4).PreferredWidth = 16.1
.Columns(5).PreferredWidth = 6.7
.Columns(6).PreferredWidth = 17.2
.Rows(1).Range.Font.Name = "Tahoma"
.Rows(1).Range.Font.Size = "10"
.Rows(1).Range.Font.Bold = True
.Rows(1).Range.Shading.BackgroundPatternColor = Word.WdColor.wdColorLightOrange
.Cell(1, 1).Range.Text = "Code"
.Cell(1, 2).Range.Text = "Description"
.Cell(1, 3).Range.Text = "Units"
.Cell(1, 4).Range.Text = "Recommended Retail"
.Cell(1, 5).Range.Text = "Disc."
.Cell(1, 6).Range.Text = "Distribution"
End With
I have also included screen grabs of Word. The highlighted text are all bookmarks. I am attempting to insert into the "Installation" bookmark.
Any ideas or suggestions would be greatly appreciated, as I have been struggling for 2 days on this now, and its putting me behind schedule.
Regards
Andre