[RESOLVED] VB.NET application with late binding - add table in a Word template at bookmark pos
Hi!
I can't find a solution, so I hope to get some help on this.
I have a VB.NET application, where I create a report using a Word template, that I fill out programmatically.
While I was using early binding, everything worked fine, but now I have to switch to late binding, so the application can be used with different office versions.
Currently I get this error:
Quote:
'Range' is not a by reference property.
on this code:
Code:
oTable = oDoc.Tables.Add(oDoc.Bookmarks.Item("myTableBookmark").Range, rCount + 2, colCount)
How can I place the table at a specific bookmark position in the word template using late binding in my application?
Re: VB.NET application with late binding - add table in a Word template at bookmark p
try setting the target range to an object prior to adding the table
Re: VB.NET application with late binding - add table in a Word template at bookmark p
Thank you very much, this worked perfectly:
Code:
Dim tgRange As Object
tgRange = oDoc.Bookmarks.Item("myBookmark").Range
oTable = oDoc.Tables.Add(tgRange, rCount + 2, colCount)
Besides, I could not find a reference, where all Word builtin property constants would be listed with their corresponding integer values.
As with late binding this does not work
Code:
oTable.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter
as there is no Word namespace avaliable, and the constant "WdParagraphAlignment.wdAlignParagraphCenter" is unknown, then I printed out the integer values while using early binding and now when using late binding I set the properties by their integer values like this:
Code:
oTable.Range.ParagraphFormat.Alignment = CInt(1)
"WdParagraphAlignment.wdAlignParagraphCenter" = 1
"WdParagraphAlignment.wdAlignParagraphRight" = 2
"WdLineStyle.wdLineStyleSingle" = 1
Re: VB.NET application with late binding - add table in a Word template at bookmark p
Edit: this was a doublepost, sorry.