Error No Document Variable Supplied Word
soon) Ruby (coming soon) Getting Started Code Samples Resources Patterns and Practices App Registration Tool Events Podcasts Training API Sandbox Videos Documentation Office Add-ins Office Add-in Availability Office Add-ins Changelog Microsoft Graph API Office 365 Connectors Office 365 REST APIs SharePoint error no document variable supplied word 2010 Add-ins Office UI Fabric Submit to the Office Store All Documentation https://www.yammer.com/ http://feeds.feedburner.com/office/fmNx Ask a error no document variable supplied mail merge question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: Error! No document variable supplied. docvariable after I replaced them all with data and try to print Microsoft Office for Developers > Word for Developers Question 0 Sign in to vote I have a macro enabled document template (.dotm) that I open and replace some named fields with real data. After I have the document completed, if I try to print it, all of the fields change to "Error! No document variable supplied". The same thing happens if I try to save it as a .PDF file. The same thing happens if I save it as a .DOCX to disable the macros first and then try to print. How do I get it to stop modifying my finished document?microwave tech Tuesday, November 20, 2012 1:52 AM Reply | Quote Answers 1 Sign in to vote Hi "drew" I suspect the problem is with how you're replacing the "named fields". From the title and the little you tell us, I'm guessing that you've inserted DocVariable fields in the document, but that there is no corresponding Document.Variable object stored in the file. So when the fields update, you get an error message. Only when a field updates does it dynamically execute the field code and content, and most field types aren't constantly updating - Word couldn't function if they did. But the actions you describe do trigger an update, which explains why you're seeing the described behavior. It becomes apparent, therefore, that DocVariable fields weren't meant to be used in this manner. If you were to pass the content to Document Variable objects in the document, it should work correctly. Something like this: ActiveDocument.Variables("field1") = "This is the text for field 1" Another possibility, since you've already written the code you have, would be to lock the fields so that they cannot update: ActiveDocument.Fields(1).Locked = True You could also remove the DocVariable fields and insert Bookmarks, instead. Bookmarks were designed to be "data targets": ActiveDocument.Bookmarks("Name").Range.Text = "This is the text for field 1"Cindy Meister, VSTO/Word MVP, my blog Marked as answer by 许阳(无锡)Moderator Frida
be down. Please try the request again. Your cache administrator is webmaster. Generated Fri, 14 Oct 2016 07:40:23 GMT by s_wx1131 (squid/3.5.20)
Forum Microsoft Office Application Help - Excel Help forum Excel Programming / VBA / Macros [SOLVED] Avoid "Error! No document variable supplied" To get replies by our experts at nominal charges, follow this link to buy points and post your thread in http://www.excelforum.com/showthread.php?t=829101 our Commercial Services forum! Here is the FAQ for this forum. + Reply to Thread Results 1 to 3 of 3 Avoid "Error! No document variable supplied" Thread Tools Show Printable Version Subscribe to this Thread… Rate This Thread Current Rating Excellent Good Average Bad Terrible Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 05-04-2012,08:45 AM #1 GCW esq View Profile View Forum Posts Registered User Join Date error no 11-25-2011 Location Lilydale, Victoria, Australia MS-Off Ver 2013 (365) Posts 63 Avoid "Error! No document variable supplied" Using DocVariables (and VBA) to write a large number of text variables from Excel file to Word doc. Getting the above error if DocVariable field is empty, and I want to get rid of the error. Successful method so far is to nest the DocVariable inside an If statement in Word, but by the time I do that error no document to all the DocVariables, the document will look horrendous when fields are showing. I could also check each variable in VBA before sending it to Word, but that would require a large number of If statements (one per variable). I could also add a space (" ") to each variable before sending it (e.g Range(FirstName) = FirstName & " "), but that then puts unwanted spaces in the Word document. I tried comparing variables in Excel with " ", with a view to accepting the " " value if the variable was empty (i.e. ""), but I haven't been able to find a function that will work with "". Any ideas, or variations on the above??? Register To Reply 05-04-2012,09:34 AM #2 JosephP View Profile View Forum Posts Forum Guru Join Date 03-27-2012 Location Ut MS-Off Ver 2003/10 Posts 7,290 Re: Avoid "Error! No document variable supplied" you could just write a separate routine that takes a DocVariable and a value and have that routine do any variable testing for you. then you only have to write one test instead of many if statements. Josie if at first you don't succeed try doing it the way your wife told you to Register To Reply 05-10-2012,10:08 PM #3 GCW esq View Profile View Forum Posts Registered User Join Date 11-25-2011 Location Lilydale, Victoria, Australia MS-Off Ver