PDA

View Full Version : Pasting tables from a range - table count not correct



MrsBopBop
10-08-2010, 04:23 AM
Hi there

Apologies if the solution is out there I tried to search but got the following error:
It has not been possible to display the page you requested for the following reason:

Read Error. An error condition occurred while reading data from the network. The system returned: (104) Connection reset by peer. Please retry your request.Contact your system administrator if you continue to experience difficulties.

My problem is that I am dynamically creating tables on a document I use the following code to copy and paste 2 tables on a page, this can be done as many times as is needed

Set rngDoc = ActiveDocument.Range(Start:=ActiveDocument.Tables(12).Range.Start, End:=ActiveDocument.Tables(13).Range.End)

rngDoc.Copy
rngDoc.EndOf wdSentence

For i = 2 To colFundProviders.Count

rngDoc.PasteAndFormat wdPasteDefault

Next

The problem with this is after one copy and paste is done
Activedocuments.tables.count is only increased by one even though I've pasted 2 tables from within the range ie table 12 and table 13)

I have tried putting loads of lines between the 2 tables just in case word is doing something funny

Failing getting a solution to this any thoughts or suggestions on how to get around it. I need bother table 12 and table 13 to be kept together?

I've spent so long on this, so if someone could help I'd be really really grateful

Thanks!

Edited to say I'm missing the table itself only from activedocument table collection, but it's physically on the page, you can see it and type in it, etc, it's just not being recognised as an additional table

fumei
10-08-2010, 09:07 AM
Are the two tables joined togetehr to become one table?

You may try adding one charcter before and after the tables to make sure the tables are completely included.

Set rngDoc = ActiveDocument.Range( _
Start:=ActiveDocument.Tables(12).Range.Start - 1, _
End:=ActiveDocument.Tables(13).Range.End + 1)


I am not exactly sure what you are doing, but it may be better to grab the tables themselves - as table object - rather than the range.