Prev: VBA code to manipulate a .jpeg Exif tag used by Explorer to store
Next: Loading order global templates in the startup folder
From: cjg.groups on 9 Feb 2009 10:46 Hello, I am using VBA to put data from Access 2003 queries into Word 2003 tables. Which is the more desirable method for putting text into a Word table cell: Document.Tables(i).Cell(r,c).Range.InsertAfter Recordset.Fields(j) Document.Tables(i).Cell(r,c).Range.Text = Recordset.Fields(j) This call will be run about 4000 times in 100 Word documents. Currently, InsertAfter completes this in a few seconds. Code I got from the newsgroups used InsertAfter, but this requires me to first delete some existing table text which "Range.Text" would otherwise overwrite.
From: Doug Robbins - Word MVP on 10 Feb 2009 05:04
I doubt that you would notice the difference, if there is any. That notwithstanding, the need to remove any existing text would definitely swing it in favour of using .Text = -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP <cjg.groups(a)gmail.com> wrote in message news:c2bfc0bf-38a5-45a0-bc23-0695a1da401d(a)v38g2000yqb.googlegroups.com... > Hello, I am using VBA to put data from Access 2003 queries into Word > 2003 tables. Which is the more desirable method for putting text into > a Word table cell: > > Document.Tables(i).Cell(r,c).Range.InsertAfter Recordset.Fields(j) > Document.Tables(i).Cell(r,c).Range.Text = Recordset.Fields(j) > > This call will be run about 4000 times in 100 Word documents. > Currently, InsertAfter completes this in a few seconds. > > Code I got from the newsgroups used InsertAfter, but this requires me > to first delete some existing table text which "Range.Text" would > otherwise overwrite. |