Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-12-2016, 07:56 AM
mktate mktate is offline prevent word fields from unlink Windows 10 prevent word fields from unlink Office 2010 64bit
Novice
prevent word fields from unlink
 
Join Date: Dec 2015
Posts: 26
mktate is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 03-12-2016, 07:57 AM
mktate mktate is offline prevent word fields from unlink Windows 10 prevent word fields from unlink Office 2010 64bit
Novice
prevent word fields from unlink
 
Join Date: Dec 2015
Posts: 26
mktate is on a distinguished road
Default

I meant to say ActiveDocument.Fields.Locked = True - not unlocked.
Reply With Quote
  #3  
Old 03-12-2016, 05:38 PM
gmaxey gmaxey is offline prevent word fields from unlink Windows 7 32bit prevent word fields from unlink Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Maybe,

If ActiveDocument.Name = "Whatever"
'Don't process the fields
Else
'Process the fields
End If
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #4  
Old 03-13-2016, 07:49 AM
mktate mktate is offline prevent word fields from unlink Windows 10 prevent word fields from unlink Office 2010 64bit
Novice
prevent word fields from unlink
 
Join Date: Dec 2015
Posts: 26
mktate is on a distinguished road
Default

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.
Reply With Quote
  #5  
Old 03-13-2016, 08:47 AM
gmaxey gmaxey is offline prevent word fields from unlink Windows 7 32bit prevent word fields from unlink Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #6  
Old 03-13-2016, 02:07 PM
mktate mktate is offline prevent word fields from unlink Windows 10 prevent word fields from unlink Office 2010 64bit
Novice
prevent word fields from unlink
 
Join Date: Dec 2015
Posts: 26
mktate is on a distinguished road
Default

That worked like a charm - thanks Greg!
Reply With Quote
Reply

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
prevent word fields from unlink Unlink source files when creating Church Directory with INCLUDEPICTURE JohnFinNC Mail Merge 3 09-18-2014 08:50 PM
prevent word fields from unlink 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft