Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

FormFields Collection is Empty

Posted on 2003-02-24
4
Medium Priority
?
375 Views
Last Modified: 2010-05-01
I simply want to access the contents of a TextBox and a ListBox on an existing document, but the FormFields collection is always empty even though the document has a TextBox called TextBox1 and a ListBox called ListBox1. What's the stupid error here? The code is as follows:-

Dim wordApp As New word.Application
Dim wordDoc As word.Document

Set wordDoc = wordApp.Documents.Open("c:\temp\MS Forms\gary.doc")
MsgBox wordDoc.FullName //this is correct
MsgBox wordDoc.FormFields.Count //this is zero

wordDoc.Close
wordApp.Quit
0
Comment
Question by:GaryDC
  • 2
4 Comments
 
LVL 3

Expert Comment

by:MCummings111400
ID: 8009938
You may be using the VBA controls for a Listbox and a Textbox and not Word Form Fields. Word Form Fields look like flat grey areas on your document. VBA Controls look like the real thing.

Why do you want the number of form fields in your document?
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 200 total points
ID: 8009961
try this instead:

For i = 0 To wdDoc.Content.InlineShapes.Count
    MsgBox wdDoc.Content.InlineShapes(i).OLEFormat.Object.Value '' the value of the control
Next
0
 

Author Comment

by:GaryDC
ID: 8010008
Well they look like the real thing. In that case could you please give me a quick pointer to accessing VBA controls?

I don't actually want the number of fields, it was just a concise way of demonstrating that it wasn't working!
0
 

Author Comment

by:GaryDC
ID: 8015854
Up and running - thank you both
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question