Link to home
Start Free TrialLog in
Avatar of GaryDC
GaryDC

asked on

FormFields Collection is Empty

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
Avatar of MCummings111400
MCummings111400
Flag of United States of America image

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?
ASKER CERTIFIED SOLUTION
Avatar of bobbit31
bobbit31
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GaryDC
GaryDC

ASKER

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!
Avatar of GaryDC

ASKER

Up and running - thank you both