?
Solved

FormFields Collection is Empty

Posted on 2003-02-24
4
Medium Priority
?
366 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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

800 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