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: Thu, 4 Sep 2008 07:00:08 -0700,    group: microsoft.public.word.vba.general        back       


VBA - Insert Row with Form Fields at End of Table   
Hi,

I am currently creating an automated form in which there's a table.  In this 
table users record various details regarding risks.  The table contains 10 
rows and seven columns with form fields in each cell (apart from the heading 
row), each risk is recorded across a row. 

My problem is that the number of rows a user might complete on this form 
could be over 10, users mostly won't go over ten, but when they do I want the 
form to automatically add a row to the end of the table with the form fields 
copied in to the new row.

Using my primative VBA knowledge I have managed to create the following but 
cannot work out how to paste my selection at the end of the table.

Sub AddRow()

ActiveDocument.Unprotect

ActiveDocument.Tables(1).Rows(2).Select

Selection.Copy

Selection.Paste

ActiveDocument.Protect wdAllowOnlyFormFields

End Sub

I have seen other posts within the forum 

(http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.word.vba.general&mid=9e7e03f1-950d-4edb-8d9b-0d1670d54d42&sloc=en-us) 

but cannot get the example to work as the code tells me there is a syntax 
error when I run it and some of the code appears in red when I paste it into 
the code window.

Please help!
date: Thu, 4 Sep 2008 07:00:08 -0700   author:   spunkymuffmonkey

RE: VBA - Insert Row with Form Fields at End of Table   
"spunkymuffmonkey" wrote:

<snip>
 
> I have seen other posts within the forum 
> 
> (http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.word.vba.general&mid=9e7e03f1-950d-4edb-8d9b-0d1670d54d42&sloc=en-us) 
> 
> but cannot get the example to work as the code tells me there is a syntax 
> error when I run it and some of the code appears in red when I paste it into 
> the code window.

If the code appears in red it simply means that the compiler cannot make 
sense of those lines.

If you are using code you got on the web, the usual reason is that longer 
lines have been split in two (or more) shorter lines when they were posted by 
a browser.

Place the cursor at the end of a red line that is followed by another red 
line. Hit "Delete" until the two lnes are one, making sure not to delete any 
actual characters.

You may have to adjust Quotes if there were any.

If you have a single red line, it maybe that the next line happens to be a 
line the compiler understands as is, but it should probaboy be brought back 
with the preceding line.

If you are not sure, post the red lines here, together with the few lines 
that precede and follow.
If the whole code is fairly short, you can post the whole thing specifying 
which lines are red.
date: Thu, 4 Sep 2008 10:22:12 -0700   author:   Jean-Guy Marcil

Google
 
Web ureader.com


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