|
Convert fields in Word to text. Once this is done, they can't be automatically updated, of course. Unlinking simply disconnects the value from a variable that could make it change again.
The first step in automating a process from Access is to be able to do it in Word. After creating a document with fields such as document properties, to ensure the values don't change when you share with others, convert the fields to text.
Download zipped BAS file you can import into your Word documents: mod_Word_UnlinkSelection_s4p__BAS.zip
If you have trouble with a download, you may need to unblock the ZIP file, aka remove Mark of the Web, before extracting the file. Here are steps to do that: https://msaccessgurus.com/MOTW_Unblock.htm
To manually convert all fields:
This code first updates each field in the selection to the stored value, and then converts it to plain text.
This works on fields in the body of a document, but not on cross-references.
Press Ctrl-A to select the entire document first or select the portion of the document you want and then run the code.
'*************** Code Start *************************************************** ' Purpose : Update and Unlink Fields in Word Selection ' Author : crystal (strive4peace) ' Code List: https://msaccessgurus.com/code.htm ' This code: https://msaccessgurus.com/VBA/Word_UnlinkFields.htm ' LICENSE : ' You may freely use and share this code, but not sell it. ' Keep attribution. Mark your changes. Use at your own risk. '------------------------------------------------------------------------------ 'module name: mod_Word_UnlinkSelection_s4p '------------------------------------------------------------------------------ Sub UnlinkSelection() '230112 strive4peace With Selection.Fields 'update fields .Update 'unlink fields .Unlink End With MsgBox "Done unlinking",, "Done" End Sub '*************** Code End *****************************************************' Code was generated with colors using the free Color Code add-in for Access
It's surprising how much code is out there with complex looping procedures to do things like select each field, grab text from the code, replace it, and then go to the next field. The answer is very simple.
If you like this site, please let me know. Donations are needed and appreciated, thank you
Here's the link for this page in case you want to copy it and share it with someone:
https://msaccessgurus.com/VBA/Word_UnlinkFields.htm
or in old browsers:
http://www.msaccessgurus.com/VBA/Word_UnlinkFields.htm
Let's connect and team-develop your application together. I teach you how to do it yourself. My goal is to empower you.
While we build something great together, I'll pull in code and features from my vast libraries as needed, cutting out lots of development time. I'll give you lots of links to good resources.
Do you want to do more with Word (or Access)?
I'd love to help you.
Email me at training@msAccessGurus
~ crystal
the simplest way is best, but usually the hardest to see