A visual basic problem in Word 2003.

E

ericm

I cannot get the value of location 1 (form field "drug1") copied to location
2 (form field "drug2") when the check box (check box "copy1") is checked. I
instead get a blank field at location 2.

The following macro ("UCFCopy1") runs upon exit of the checkbox field :

Sub UCFCopy1()
If ActiveDocument.FormFields("copy1").CheckBox.Value = True Then
ActiveDocument.FormFields("drug2").Result =
ActiveDocument.FormFields("drug1").Result
Else: ActiveDocument.FormFields("drug2").Result = "B"
End If
End Sub

Note that "B" in the above macro is to simply test the value passed through
the macro. When this macro runs and the box is checked, nothing appears in
the form field "drug2" (the text from "drug1" should appear but does not).
When the checkbox is unchecked the form field "drug2" displays "B".

Also note that the screen (on my computer) flashes TWICE when the checkbox
is NOT CHECKED and only flashes ONCE when the checkbox is checked, as though
it is refreshing the contents of the entire screen. I have tried various
variables, declaring variables and removing formatting in the macro/document
without success.

The document in which this macro is executing contains maybe 100 assorted
form fields, checkboxes and field references.

I used the exact same macro in another document I called "filltest" to
simply test the macro's integrity. The "filltest" document consists of
little more than two form fields ("drug1" "drug2") and a checkbox ("copy1").
The macro works there.

Any insight you have would be appreciated.
 
D

Doug Robbins - Word MVP on news.microsoft.com

The same code functions correctly here.

--
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, originally posted via msnews.microsoft.com
 
A

ak_edm

I'll put the following questions out here for consideration :

1) Would the complexity of a document (e.g. tables, text formatting) affect
the ability for a macro to move variable values from one form field to
another?

2) Would the number of form fields and check-boxes in a document affect the
ability for a macro to retrieve and hold a variable (i.e. the text of a form
field)? For example, maybe Word can only handle a certain number of form
fields, check-boxes, etc... until instability occurs. I ask because that
appears to be the major difference between the document ("filltest") that
works and the other document that doesn't.

3) Is there a way to upload the document in question (Word 2003 doc), so it
can be reviewed? This is a document I use at work, and I've been "ok'd" to
uploaded it if needed.

- Eric
 
D

Doug Robbins - Word MVP on news.microsoft.com

I am pretty certain that the answers to questions 1 and 2 is No. Re 3, send
it to me at (e-mail address removed)

You must remove the uppercase letters to get the correct email address.

--
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, originally posted via msnews.microsoft.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top