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 / May 2008

Tip: Looking for answers? Try searching our database.

Macro to unlink in nonprimary header

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Olympian151 - 26 May 2008 07:26 GMT
I have written a macro that removes all fields from the document after the
user populates it using dialog boxes (Ask fields).  My problem is, I included
coding that unlinked all fields in the header, which I thought was a grand
idea until I realized that it also unlink the Page field!

Is there a way to "protect" the page field so it can not be unlinked when I
run my macro? Or as a fall back, is there a way, using a macro, that I unlink
only the two fields I want unlinked (date and reference number) and leave the
page field intact?

Thanks for any help, I've been searching web but found only global
replacements.
Graham Mayor - 26 May 2008 09:52 GMT
You can conditionally unlink fields eg

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

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> I have written a macro that removes all fields from the document
> after the user populates it using dialog boxes (Ask fields).  My
[quoted text clipped - 9 lines]
> Thanks for any help, I've been searching web but found only global
> replacements.
Olympian151 - 27 May 2008 20:30 GMT
thank you Graham!! it worked great with just the littlest modification for
the header and field!  I was too focused on just protecting the Page field.  
Thank you again!!

> You can conditionally unlink fields eg
>
[quoted text clipped - 19 lines]
> > Thanks for any help, I've been searching web but found only global
> > replacements.
Graham Mayor - 28 May 2008 06:30 GMT
You are welcome :)

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> thank you Graham!! it worked great with just the littlest
> modification for the header and field!  I was too focused on just
[quoted text clipped - 31 lines]
>>> Thanks for any help, I've been searching web but found only global
>>> replacements.
 
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.