Creating templates from VB.NET

  • Thread starter Johnny E. Jensen
  • Start date
J

Johnny E. Jensen

Hello NG

I am creating templates from VB.NET besause with VB i have the abillity to
use late binding and therefore don't have to code to a specific version of
Word. (as long i don't use specific version 2007 commands to a version 2003
Word I know that)

When i use spec relation to Word 2007 - setting the reference to Microsoft
Word 12.0 object the following works fine.

Dim objTable As WD.Table
Dim objBorder As WD.Border
Dim objRange As WD.Range

objRange = objDoc.Range(Start:=0, End:=0)
objTable = objDoc.Tables.Add(Range:=objRange, NumRows:=3,
NumColumns:=20)

With objDoc.Bookmarks
.Add(Name:="WinnerCRM_OfferTable", Range:=objTable.Cell(1,
1).Range)
.Add(Name:="WinnerCRM_OfferLines", Range:=objTable.Cell(2,
1).Range)
End With

But when i remove the reference to Microsoft Word 12.0 object the following
(Changed code) don't work.

Dim objTable As Object
Dim objBorder As Object
Dim objRange As Object

objRange = objDoc.Range(Start:=0, End:=0)
objTable = objDoc.Tables.Add(Range:=objRange, NumRows:=3,
NumColumns:=20)

With objDoc.Bookmarks
.Add(Name:="WinnerCRM_OfferTable", Range:=objTable.Cell(1,
1).Range) <----- ERROR HERE
.Add(Name:="WinnerCRM_OfferLines", Range:=objTable.Cell(2,
1).Range)
End With

The error recieved is - The type is not a referenced by type????

Can anyone give me a hand here??

Kind regards

Johnny Jensen
 
D

Doug Robbins - Word MVP

To use Late Binding, you must create and set an object to the application
that you want to use. You do not appear to have done that.

See the article "Early vs. Late Binding" at:
http://www.word.mvps.org/FAQs/InterDev/EarlyvsLateBinding.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top