Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

Inserting table at bookmark instead of top of document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jesper Fj?lner - 04 Mar 2005 23:27 GMT
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)

Signature

Jesper Fj?lner
Denmark

Helmut Weber - 05 Mar 2005 14:44 GMT
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/
Jesper Fj?lner - 07 Mar 2005 09:10 GMT
> Dim oWrd As Word.Application
> Dim oDoc As Word.Document
[quoted text clipped - 3 lines]
> Set oDoc = oWrd.Documents.Open("c:\test\dialoge.doc")
> Set oTbl = oDoc.Tables.Add(oDoc.Bookmarks("Marktable").Range, 1, 6)

Great, thank!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.