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 / January 2006

Tip: Looking for answers? Try searching our database.

Selecting a Date Field in a Footer to Unlink It

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Aaron Babel - 10 Jan 2006 18:12 GMT
The following code finds a date field in the
active document and unlinks it, to leave
the current year as text:
   ...
   Selection.GoTo What:=wdGoToField, Name:="Date"  
   Selection.Fields.Unlink
   ...

Additionally, the same date field appears in the footer of
the last page of the active document. I wrote this
code to find and unlink it:
  ...
  Selection.GoTo What:=wdGoToPage, Which:=wdGoToLast

  With ActiveDocument.ActiveWindow.View
       .Type = wdPrintView
       .SeekView = wdSeekCurrentPageFooter
   End With

   Selection.GoTo What:=wdGoToField, Name:="Date"
   Selection.Fields.Unlink

However, it doesn't select the fields, and, consequently,  
it doesn't unlink it.  What am I missing? Or is this simply
not possible?

I hope I've been clear. Thanks for your consideration.

Aaron
Doug Robbins - Word MVP - 10 Jan 2006 18:59 GMT
Use:

Dim afield As Field
For Each afield In ActiveDocument.Fields
   If afield.Type = wdFieldDate Then
       afield.Unlink
   End If
Next afield

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> The following code finds a date field in the
> active document and unlinks it, to leave
[quoted text clipped - 25 lines]
>
> Aaron
Aaron Babel - 11 Jan 2006 15:32 GMT
Much appreciated, Doug.

I've left the "Record Macro" stage about a year ago,
so I'm in that in-between stage of learning how to
optimize my code. Thanks for sharing with me a view
of the "other" side of "General Simplicity." You've been
credited in my code comments.

Aaron

> Use:
>
[quoted text clipped - 34 lines]
> >
> > Aaron
 
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.