?
Solved

How to :Insert Word Table into Word Bookmark

Posted on 2003-03-12
4
Medium Priority
?
606 Views
Last Modified: 2012-08-14
I have Word document with default Bookmark
Simply I wanr to replace this bookmark with dynammic ms Word table that I populated using VB 6

Here is my Code

Dim docNew As Word.Document
 Dim tblNew As Table
Dim docApp As Word.Application
Dim docSave As Word.Document
Dim intX As Integer
Dim intY As Integer

    Set docApp = CreateObject("Word.Application")
    Set docSave=docApp.Documents.Open("C:\temp\new.doc")
    Set docNew = Documents.Add
    Set tblNew = docNew.Tables.Add(Selection.Range, 3, 5)
    With tblNew
    For intX = 1 To 3
        For intY = 1 To 5
            .Cell(intX, intY).Range.InsertAfter "Cell: R" & intX & ", C" & intY
        Next intY
    Next intX
    .Columns.AutoFit
    End With

' This Part does not wok. Once I populated tblNew I want to replace Bookmark with actual table
If (docSave.Bookmarks("OK").Name.Exists = True) Then
 .....
 Set docSabe.Bookmarks("OK").Range=TblNew.Range
End If

Range does not work for table
Plase advice

Regards
Alex

   
0
Comment
Question by:Saltebor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 10

Accepted Solution

by:
aeklund earned 2000 total points
ID: 8121369
' This Part does not wok. Once I populated tblNew I want to replace Bookmark with actual table
If (docSave.Bookmarks.Exists("OK") = True) Then
  tblNew.Select
  Selection.Copy
  docSave.Bookmarks("OK").Select
  Selection.Paste
End If


Above is modified code to perform what you are asking for... to verify the change, add this line to make word visisble and you will see the changes:

docApp.Visible = True
0
 

Expert Comment

by:CleanupPing
ID: 9056398
Saltebor:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9664506
Moderator, my recommended disposition is:

    Accept aeklund's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month7 days, 20 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question