Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

Can I disable or skip "fillin" fields.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike Kaplan - 17 Mar 2005 21:17 GMT
I have a need to write a VB program, which will use OLE-Automation to
automatically open and print a series of MS Word documents (Word 97 right
now, but soon Word 2003 as well).  It seems for some of these documents, the
original authors included fill-in fields, in the document header.  Each time
my program opens, and then attempts to print the document, the fill-in prompt
appears.

This program is supposed to require no user-intervention!  Right now, I need
to manually click "cancel" twice for these documents.  Is there any way to
programatically disable or "skip" these fields?

Thanks
Jay Freedman - 18 Mar 2005 03:23 GMT
>I have a need to write a VB program, which will use OLE-Automation to
>automatically open and print a series of MS Word documents (Word 97 right
[quoted text clipped - 8 lines]
>
>Thanks

Hi Mike,

Assuming oWord is the Word application object in your VB program, if
you execute the line

  oWord.ActiveDocument.Fields.Locked = True

then none of the fields in the document will update until you reset
the value to False.

If you need some fields to update (such as Date and Time fields) but
not others, you can loop through the document's fields and only lock
the ones that are fillins:

   Const wdFieldFillIn = 39
   Dim oFld As Word.Field
   For Each oFld In oWord.ActiveDocument.Fields
       If oFld.Type = wdFieldFillIn Then
           oFld.Locked = True
       End If
   Next oFld

--
Regards,
Jay Freedman
Microsoft Word MVP         FAQ: http://word.mvps.org
Greg Maxey - 18 Mar 2005 03:36 GMT
Jay,

Thanks.  I was this close to posting a solution this afternoon and got
called away to as staff meeting :-(

Sub Test()
Dim oFld As Word.Field
 For Each oFld In ActiveDocument.StoryRanges(wdPrimaryHeaderStory)
   If oFld.Type = wdFieldFillIn Then
     oFld ?
   End If
 Next oFld
End Sub

I don't know how I missed "locked'

Signature

Greg Maxey/Word MVP
A Peer in Peer to Peer Support
http://gregmaxey.mvps.org/word_tips.htm

>> I have a need to write a VB program, which will use OLE-Automation to
>> automatically open and print a series of MS Word documents (Word 97
[quoted text clipped - 30 lines]
>        End If
>    Next oFld
Jay Freedman - 18 Mar 2005 16:19 GMT
Hi Greg,

I missed the statement in the original post that the field is in the header.
My macro wouldn't have locked any fields there. What's needed is the
combination of our macros:

   Const wdFieldFillIn = 39
   Dim oFld As Word.Field
   For Each oFld In _
         oWord.ActiveDocument.StoryRanges(wdPrimaryHeaderStory).Fields
       If oFld.Type = wdFieldFillIn Then
           oFld.Locked = True
       End If
   Next oFld

Signature

Regards,
Jay Freedman
Microsoft Word MVP          FAQ: http://word.mvps.org

> Jay,
>
[quoted text clipped - 46 lines]
>>        End If
>>    Next oFld
Greg - 18 Mar 2005 16:28 GMT
Jay,

What is the significance of:
Const wdFieldFillIn = 39 ?
Jay Freedman - 19 Mar 2005 04:33 GMT
>Jay,
>
>What is the significance of:
>Const wdFieldFillIn = 39 ?

The OP said he was working in VB. Unless he's doing early binding, VB
doesn't have access to the VBA library that defines the values of
Word's constants, so you have to declare them in the VB code. Since
most non-Word folks don't know how to find the values (in the Object
Browser), I thought it would be helpful to include that one in my
answer.

--
Regards,
Jay Freedman
Microsoft Word MVP         FAQ: http://word.mvps.org
Greg Maxey - 19 Mar 2005 04:39 GMT
Jay,

Goes to show how little I know.  I didn't know that there was a difference
between VB and VBA.  I have a lot to learn.

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

>> Jay,
>>
[quoted text clipped - 7 lines]
> Browser), I thought it would be helpful to include that one in my
> answer.
Mike Kaplan - 22 Mar 2005 19:21 GMT
Greg and Jay,

Thank you both for your suggestions!  I would have got to them sooner, but I
was out sick and had trouble accessing the forum yesterday.  I will try these
out ASAP.  Hopefully, I have no more questions.

Thanks!
Mike

> Jay,
>
[quoted text clipped - 12 lines]
> > Browser), I thought it would be helpful to include that one in my
> > answer.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.