Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: 12 Nov 2005 11:06:24 -0800,    group: microsoft.public.word.vba.customization        back       


Better Copy and Paste in word for tables   
I wrote a macro that retrieves data from a database, populates a table
using bookmarks and then copies this table and pastes it at the end of
the document before moving to the second row of data.

I am looking for improving the efficiency and performance of this
macro.

1. Is there a better copy and paste algo for tables

2. can i clear the clipboard between each copy and paste. will it
improve the performance.

3. any other suggestions

Some pieces of the macro pasted below

   Set oWorkSpace = session.GetWorkSpace
   Set oQueryDef = oWorkSpace.GetQueryDef(strQueryName)

   ' REM execute the query
   Set oResultSet = currentsession.BuildResultSet(oQueryDef)
   oResultSet.Execute
   longNumColumns = oResultSet.GetNumberOfColumns ' no of columns

   ' Start populating the template table
   Row = 1
   Status = oResultSet.MoveNext
   NumRows = 0
   Do While Status = 1
     'REm Go to the template table
     Selection.GoTo What:=wdGoToTable, Which:=wdGoToFirst, Count:=1,
Name:=""

     Row = Row + 1
     Dim strBookName As String
     For Column = 2 To longNumColumns
       'REM Fill it in the bookmark
        strBookName = "field" & (Column - 1) ' field1, filed2 etc
        UpdateBookmark strBookName,
CStr(oResultSet.GetColumnValue(Column))
     Next

     'REM Done with the row, Copy the table and paste it below
     Selection.Tables(1).Select
     Selection.Copy

     Selection.EndKey Unit:=wdStory
     Selection.InsertBreak Type:=wdPageBreak
     Selection.PasteAndFormat (wdPasteDefault)

     ' Move Next
     Status = oResultSet.MoveNext
     NumRows = NumRows + 1
   Loop

   ' Clear the first table
   CleanAllBookMarks

   Exit Sub
date: 12 Nov 2005 11:06:24 -0800   author:   unknown

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us