FillIn Field and office automation

B

Bjoern Wolfgardt

Hi NG,

I am a Office Newbee (okay I know something about Outlook and I am able to
write a letter with Word). I have to write a little tool that will open a
Word document and print it. I used c# to do this. It works like a charme for
every document except one. The document popps up a input box. So I tried to
find out what it is. I found out it is a FillIn Field and that FillIn Fields
are MailMerge Fields. I don't have any idea what a Mail Merge Field is. But
I found out where to look for the fields in my little app.

foreach(Microsoft.Office.Interop.Word.Field fld in WordDoc.Fields)
{
if(fld.Type == Microsoft.Office.Interop.Word.WdFieldType.wdFieldFillIn)
{
// found it so deactivate it
}
}

But this code never finds the field. There is no FillIn Field.
So where do I have to look for the field. The field is in the footnote of
page one. Is there a special footnote field collection or something else.

thx in advance
Bjoern
 
P

Peter Jamieson

Word has a number of "Stories" representing text and objects in the main
body, headers, footers, and so on. You will need to surround your existing
loop by at least the following (sorry, I'm guessing the C# so you'll need to
name everything correctly)

foreach(Microsoft.Office.Interop.Word.Range oRange in WordDoc.StoryRanges)
{
// your code here
}

However, even that may not get absolutely every possible FILLIN field. And
if you are trying to write code to print /any/ document, you need to know
that you can encounter other dialog boxes that are not easy to disniss
(because you don't know they have popped up) - e.g. if the document is a
mail merge main document attached to a data source that Word cannot find.
I found out it is a FillIn Field and that FillIn Fields
are MailMerge Fields

FWIW a Fillin field, when executed, pops up a simple dialog box that allows
the user to enter text, which is then inserted as the "result" of the fillin
field in the document. Although it is classified as a "Mail merge" field, it
can be used in any document.
 
C

Charles Kenyon

It could be an ASK field or it could be from a VBA project: an Input Box or
a UserForm. These can look like the popup from a Fill-In field. All of them,
though, would have to have a vba project to launch them, so check that
document for macros.
--

Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
B

Bjoern Wolfgardt

Hi,

thx for your response, the problem is that I can't tell the user to use an
ASK. I need to print every document that comes in. But Peter leads me to
think about how to handle some message boxes that I can't turn off because
they are error messages.
But your hint to check for macros is also important for me.

thx
Bjoern
 
B

Bjoern Wolfgardt

Hi Peter,

thx for your reply. You are the man. It was right. I am now able to turn of
Fill-In and Ask Fields.
But you are right that I need to print every document. So Error Messages
can't be turned off.

I think I will put the print methode in a single thread that I will
terminate if the thread didn't stop after n-minutes. Now this little
application becomes interessting because I havn't tried something like this
before :)

thx again
Bjoern
 
P

Peter Jamieson

Two things that may help:
a. setting the Word Application's .DisplayAlerts to wdAlertsNone may
prevent /some/ alerts from displaying
b. with mail merge main documents that cannot find their source, you can
create a new blank document and insert|document the mail merge main
document, which then is treated as if it is /not/ a mail merge main
document. But it may break the formatting - in particular you may lose
headers/footers, especially in a multi-section document.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top