Inserting table at bookmark instead of top of document

  • Thread starter Jesper Fjølner
  • Start date
J

Jesper Fjølner

Hi all,

I'm totally new to word vba but used to Access vba.
I'm opening af word document from Access and would like to insert a table
starting at a bookmark ("start").
However I can only find out how to put the table at the very beginning of
the document with range (rngDoc).
How do I start the table at the bookmark, "start" instead of at the
beginning of the document.
(There maybe other stuff wrong with the below code).
Thanks for any help.
------------------------------
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oTbl As Word.Table

Set oWord = CreateObject("word.application")
oWord.Visible = True

Set oDoc = oWord.Documents.Add("c:\filename.dot")
Set rngDoc = oDoc.Range(Start:=0, End:=0)
Set oTbl = oWord.Selection.Tables.Add(rngDoc, 1, 6)
 
H

Helmut Weber

Hi Jesper,
like this, tested from Excel:
---
Dim oWrd As Word.Application
Dim oDoc As Word.Document
Dim oTbl As Word.Table
Set oWrd = New Word.Application
oWrd.Visible = True
Set oDoc = oWrd.Documents.Open("c:\test\dialoge.doc")
Set oTbl = oDoc.Tables.Add(oDoc.Bookmarks("Marktable").Range, 1, 6)
oTbl.Style = "Tabelle Einfach 1" ' German version
---
Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
J

Jesper Fjølner

Dim oWrd As Word.Application
Dim oDoc As Word.Document
Dim oTbl As Word.Table
Set oWrd = New Word.Application
oWrd.Visible = True
Set oDoc = oWrd.Documents.Open("c:\test\dialoge.doc")
Set oTbl = oDoc.Tables.Add(oDoc.Bookmarks("Marktable").Range, 1, 6)

Great, thank!
 

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