Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why cant I hand on a string to FormFields using a variable????

Status
Not open for further replies.

mmtraining

IS-IT--Management
Mar 18, 2002
104
DE
I have got a form field in Word called se2_2a. If I set it to 0 using the line
Code:
ActiveDocument.FormFields("se2_2a").Result = 0
then I have no problems whatsoever.

If I build the name using a series of loops to get the numbers right and then test to see if the bookmark exists (it does and is found) then I get the problem "is not in the collection" (see below) when the line where I set the result is reached.

It is as if FormFields can't deal with a text variable.

WAAAAAAAGGGHHHH!!!!!!!!!!!!!!!


Code:
Feldnamen1 = "SE" & Aktivitaet & "_" & Aktivitaet2 & "A"
            
If ActiveDocument.Bookmarks.Exists(Feldnamen1) = True Then
     ActiveDocument.FormFields(Feldnamen1).Result = 0
End If

Any ideas?

Carol
Berlin, Germany
 
A couple of ideas :-
1. Feldnamen1 is set up in uppercase by your code instead of lowercase as in the document.

2. Try putting 'Msgbox(Feldnamen1)' to check that it is OK.

3. When all else fails, suspect that the code sheet has become corrupted. Copy/Paste all the code to a text editor such as notepad. Delete the original sheet. Copy/Paste from Notepad to a new sheet. Regards
BrianB
** Let us know if you get something that works !
================================
 
Thanks, Brian,

I have already done the first two things, tried upper/lower case and given out the name using debug.print. I also tried converting each part of the contents into a string. In the end I selected the bookmark (which is also the name of the form field) and then gave the first (and only) form field in the selection the value 0.

I'll try out your tip about a corrupted sheet.

All the best

Carol, Berlin :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top