Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word vba or vb6 problem 2

Status
Not open for further replies.

jslmvl

Vendor
Jan 26, 2008
268
GB
Hi,

In vb6, I have opened a word document, but don't know how to paste something after a table in the document. In fact, I even don't know how to find the name of the table.

Any idea? Can you help?
 

Let me get it straight:
You have a Word document with some text, a table, and then some text under the table. And you want to insert a text after that table but before the last piece of text?

What I would do, if possibile, is place a Bookmark in the location where you want to insert the text, and use GoTo MyBookMark - and you are there.

Have fun.

---- Andy
 
Thank you!
Yes, I want to insert a text right after a table.
Can I say to VB+Word that I want to insert a text after Tables(i)?
 
Let's say you only have 1 table. It is then "thisdocument.tables(1)", by definition.
Code:
thisdocument.Tables(1).Select
selection.MoveDown

_________________
Bob Rashkin
 
When I fun your code, got error message

Run-time error '91':
Object variable or With block variable not set

at this line: Selection.MoveDown
 
Obviously:
[!]yourWordApplicationObject.[/!]Selection.MoveDown

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yes!! Now, it works.
Thank you for all your helps.
 
In fact, I even don't know how to find the name of the table."

Tables do not have names.

You can do it without using Selection. As PHV points out though, you DO have to use the appropriate application object.
Code:
Dim r As Word.Range
Set r = [i][COLOR=red]ApplicationObject[/color red][/i].ActiveDocument.Tables(1).Range
With r
   .Collapse 0
   .InsertAfter "hello world"
End With
The above inserts the text "hello world" immediately after Table(1).


Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top