troubleshooting Question


Avatar of calebS
calebS asked on
Visual Basic Classic
3 Comments1 Solution903 ViewsLast Modified:
This question relates to the same problem as posed in my question (

My code is as below.

The user has fields marked in the document (ie '###_fieldname_###'), I present the user with a macro in which the user can fill in textboxes, these textboxes have tags that correspond to fieldnames.

The macro I run then replaces all occurrences of the field in the document with the text associated with the textbox per the textbox.tag.

What I am trying to do is have the form run an initial check to see whether each tbox.tag exists in the document, and then to disenable the textbox accordingly.

When I run this code however it ends up with all the textboxes being grey.

Private sub checkform()
  dim tbox as textbox
  for each tbox in tboxCollection
    if Activedocument.Content.Find.Text = tbox.Tag Then
      tbox.Enabled = true
      tbox.BackColor = white
      tbox.Enabled = False
      tbox.BackColor = grey
    end if
End Sub

**Note I have also tried a variation of the above code in which I first disenabled all the boxes, and then ran the if-then statement only enabling the appropriate boxes, not disenabling any.
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros