×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

empty form fields

empty form fields

empty form fields

(OP)
I'm trying to automate our price qoute sheet with a form i made with formfields in microsoft word.  I have little experience with VBA and only in reference to excel. The form fields are within a three column eight row table with one form field in each cell. I would like a code that detects whether a form field Total7 is empty and if so deletes that entire row (row 8) from the table.  It has been awhile sense i've done anything like this so any help would be great.

Thanks
Rory

RE: empty form fields

You need to figure out how VBA addresses a formfield in Word (object browser is your friend here).  Once you know what it's object name is, then you will do something like:

dim strContents as String
strContents = formfield("Total7").text

Once you've located the form field object in the object browser, you can hit F1 to call the help, which will have code examples and show you how to address it properly in your code.

A simple If statement or a Case statement will let you set the course for if it's empty or not.

RE: empty form fields

Formfield values are accessed via: ActiveDocument.FormFields("Text7").Result
Tables via (for example):
ActiveDocument.Tables(1).Rows(8).Delete

Cheers,
Joerd

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.

RE: empty form fields

(OP)
Thank you, I have managed to get that far on my own but have now hit another bug.  Could anyone suggest a way to verify whether a formfield exists.

RE: empty form fields

Two ways:
1. Loop through the formfields (For..Each) and verify the names to see if it matches the one you're looking for.
2. Set error trapping (On Error Goto xxx), call the formfield, and handle the error if it occurs.

Let me know if you can work it out based on these suggestions.

Cheers,
Joerd

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources