Word document - can't add text after table

pbassett

Active Member
Joined
May 5, 2004
Messages
358
I have created a Word document and populated it with text followed by a table containing data from query results, but when I try to add text after the table that text is inserted into cell(1,1) of the table!

This code follws the table creation. Any help getting it to actually start after the table is appreciated!

Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add
Set wrdSelection = wrdApp.Selection
Set wrdRange = wrdDoc.Range

[create table here]

Set wrdRange = wrdSelection.Tables(1).Range
wrdRange.Collapse wdCollapseEnd
wrdRange.InsertParagraph
wrdRange.Collapse wdCollapseEnd

wrdSelection.TypeText "Group A Spring 2010"
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Right before adding the final text, add the command:

wrdSelection.EndKey Unit:=wdStory

That's the equivalent of Ctrl-End: move to end of file.
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,261
Members
452,901
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top