Tables work differently when Word is Hidden?

J

Jerry

I have a table with 3 columns that I programmatically add
text to. Once the text is added to the last cell I want
to get out of the table and then begin adding regular
text. The following code is a sample of how I am doing
this. I run this code from Access and hide the instance of
Word. My problem is that the code works fine when Word is
visible, however once I hide it I get different results.
Is there anything special that I need to do when Word is
hidden to work with text and tables?

wdApp.Selection.TypeText Text:="- Document Findings"
wdApp.Selection.TypeParagraph
wdApp.Selection.TypeText Text:="- Prepare Consensus
Scorebook"
wdApp.Selection.TypeParagraph
wdApp.Selection.TypeText Text:="- Prepare for Site
Visit"
wdApp.Selection.Font.Bold = True
wdApp.Selection.Font.Name = "arial"

wdApp.Selection.MoveEnd unit:=wdTable
wdApp.Selection.MoveDown unit:=wdLine
wdApp.Selection.TypeParagraph
wdApp.Selection.Move unit:=wdLine

wdApp.Selection.TypeText Text:="Stage 3, Site
Visit Review"
wdApp.Selection.TypeParagraph
wdApp.Selection.TypeParagraph

Thanks in advance for any assistance!
Jerry
 
D

Doug Robbins - Word MVP

I would suggest that you try and avoid using the Selection object. If you
are inserting something into a table, it is much better to use the .Range of
the cell into which you want to insert the informaiton.

To move to the end of the document after the table, use

Dim myrange as Range.
Set myrange = ActiveDocument.Range
myrange.Collapse wdCollapseEnd

then use

myrange.InsertBefore

for anything that you want to insert.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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