Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Word VBA help?

Thread Tools
 
Search this Thread
 
Old 10 December 2003, 09:47 AM
  #1  
nkh
Scooby Regular
Thread Starter
 
nkh's Avatar
 
Join Date: May 2002
Posts: 633
Likes: 0
Received 0 Likes on 0 Posts
Post

I am trying to copy a formfield from row 2 of a table down the whole column and then name it appropriately with the following code. The code fails at the rng.FormFields(1).Name = nkh
line.

Any ideas?

Dim rowCount As Integer
Dim colCount As Integer
Dim t As Table
Dim bmName As String
Dim rng As Range
Dim nkh As String

Set t = ActiveDocument.Tables(1)

For colCount = 1 To t.Columns.Count
Set rng = t.Cell(2, colCount).Range
rng.MoveEnd Unit:=wdCharacter, Count:=-1
If rng.FormFields.Count >= 1 Then
'There is a formfield to copy and rename
rng.FormFields(1).Copy
bmName = rng.FormFields(1).Name
For rowCount = 3 To t.Rows.Count
Set rng = t.Cell(rowCount, colCount).Range
rng.MoveEnd Unit:=wdCharacter, Count:=-1
rng.Paste
nkh = "Tbl" & bmName & rowCount
MsgBox (nkh)
If ActiveDocument.Bookmarks.Exists(nkh) Then MsgBox ("HELP")
rng.FormFields(1).Name = nkh
Next
End If
Next
End Sub
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
johnfelstead
ScoobyNet General
85
22 March 2001 12:02 PM
SDB
ScoobyNet General
2
12 January 2001 10:43 AM
Trout
ScoobyNet General
72
30 November 2000 08:23 AM
Richard Askew
ScoobyNet General
3
27 November 2000 01:43 PM
mattski
ICE
5
02 November 2000 03:26 PM



Quick Reply: Word VBA help?



All times are GMT +1. The time now is 04:19 AM.