#1
|
|||
|
|||
prevent word fields from unlink
I have a userform that opens multiple word documents and then fills in docvariables via user form questions. When completed, I used ActiveDocument.Fields.Update then ActiveDocument.Fields.Unlink as we do not want to keep the fields in these completed documents. However, I have added one additional document and would like to keep all of the data/fields and NOT have this one document unlink fields. I have a separate macro button for this separate file, but users are sometimes not closing/saving the new file first, so then when they run the remainder of the userform, they end up unlinking the fields on all documents, including the one where we don't want it to. I tried ActiveDocument.Fields.Unlocked = True, but I think unlocking must only prevent field updates and does not prevent unlinking. Is there VBA that would protect this one document's fields while other active documents are being unlinked? Thanks. |
#2
|
|||
|
|||
I meant to say ActiveDocument.Fields.Locked = True - not unlocked.
|
#3
|
|||
|
|||
Maybe,
If ActiveDocument.Name = "Whatever" 'Don't process the fields Else 'Process the fields End If |
#4
|
|||
|
|||
The documents are templates so they don't have any names yet- just document(1), document(2), etc. - how do I determine which document number would be the one not to unlink for every case (I think it may be different depending upon how the user makes choices in the userform)? This "special" document will have a phrase in it that will not be in the other document templates, so maybe I could say, if active document does not contain "phrase" then ActiveDocument.Fields.Unlink - I just can't find the VBA to say "if active document does not contain "phrase" - thanks for the previous reply.
|
#5
|
|||
|
|||
Do the templates have names?
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey If ActiveDocument.AttachedTemplate.Name = "Name of the template I don't want to unlink fields in.dotm" Then 'don't unlink fields Else Unlink Fields End If lbl_Exit: Exit Sub End Sub |
#6
|
|||
|
|||
That worked like a charm - thanks Greg!
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Word tables: prevent word from highlighting whole cell when I highlight text | skylark53 | Word | 2 | 08-04-2015 08:12 AM |
Unlink source files when creating Church Directory with INCLUDEPICTURE | JohnFinNC | Mail Merge | 3 | 09-18-2014 08:50 PM |
How do I prevent the "author" or "owner" fields from being changed? | Bones | Word | 3 | 06-08-2012 12:15 AM |
Word 2010 - DOCX File with fields -> PDF with fields | senglory | Word | 2 | 03-27-2012 10:10 AM |
Unlink Chapter Numbering from Template | Daved2424 | Word | 0 | 11-26-2010 11:44 AM |