Tables in asp.net

S

Steve

I'm using the foolowing command to create a table:
"tbl = oWordDoc.Tables.Add(oWordApp.Selection.Range, 30, 4)"

At the moment this table is always going in at the start of the document,
how can i get it to go in at acertain point?
I don't mind if i have to set a bookmark, or at a certain text point (which
is preffered).

Any ideas what I need to do?
 
H

Helmut Weber

Hi Steve,

might be, that your selection is always at the start
of the document. This one works for me:

Sub AddTable()
Dim r As Range
Set r = Selection.Range ' initialize
r.Start = 20 ' character 20 in doc
r.End = 20
ActiveDocument.Tables.Add r, 5, 5
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
S

Steve

How can I get it to go to a certain point? Some documents it might be at the
start, others a few pages down. Easiest way to put it in would be with
bookmarks but not sure how to do it.

would something like " r.start = bookmark("name") " work?
 
H

Helmut Weber

Hi Steve,
would something like " r.start = bookmark("name") " work?

almost certainly, best when using exclusive bookmark,
which looks like ][.
In case of an inclusive bookmark, like [mark1text],
the bookmark and it's text will vanish.

Sub AddTable()
With ActiveDocument
.Tables.Add .Bookmarks("Mark1").Range, 5, 5
End With
End Sub

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
S

Steve

I'm trying to use:

tbl = oWordDoc.Tables.Add(oWordDoc.BookMarks("RelParty").Range, NoRParty, 4)

but i keep getting an error of:

Interface 'Word.Bookmarks' cannot be indexed because it has no default
property

Any idea what i'm doing wrong?


Helmut Weber said:
Hi Steve,
would something like " r.start = bookmark("name") " work?

almost certainly, best when using exclusive bookmark,
which looks like ][.
In case of an inclusive bookmark, like [mark1text],
the bookmark and it's text will vanish.

Sub AddTable()
With ActiveDocument
.Tables.Add .Bookmarks("Mark1").Range, 5, 5
End With
End Sub

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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