Error No Document Variable Supplied
Contents |
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 error no document variable supplied mail merge Microsoft Graph API Office 365 Connectors Office 365 REST APIs SharePoint Add-ins
Error No Document Variable Supplied Word 2007
Office UI Fabric Submit to the Office Store All Documentation https://www.yammer.com/ http://feeds.feedburner.com/office/fmNx Ask a question Quick access Forums home
Vba Error No Document Variable Supplied
Browse forums users FAQ Search related threads Remove From My Forums Answered by: Error! No document variable supplied. after I replaced them all with data and try to print Microsoft Office for
Docvariable
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("
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 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 https://social.msdn.microsoft.com/Forums/office/en-US/e76a2d65-1588-4f41-b295-793a605099dc/error-no-document-variable-supplied-after-i-replaced-them-all-with-data-and-try-to-print?forum=worddev to Threaded Mode 05-04-2012,08:45 AM #1 GCW esq View Profile View Forum Posts Registered User Join Date 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 http://www.excelforum.com/showthread.php?t=829101 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 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 o
with a field update. However, if any of the values http://www.vbaexpress.com/forum/archive/index.php/t-3123.html are null, I get "Error! No document variable supplied." I would http://www.office-forums.com/threads/new-document-displays-error-no-document-variable-supplied.1885453/ prefer that where variable is empty, nothing appears. Thank you. MOS MASTER05-08-2005, 06:05 AMHi Lev, :D A bit more background please... Could you be a little more specific on the code you are using to write the values and update of the error no variables. And could you tell us exactly what kind of variables you are using? (Inserted in the document how?) Enjoy! :thumb Levski05-08-2005, 06:34 AMThe variables are entere through automation; this is pascal but you will get the drift: WordDoc.Variables.Add('Name', Name); WordDoc.Variables.Add('Address1', tAddress1); WordDoc.Variables.Add('Address2', tAddress2); WordDoc.Variables.Add('Address3', tAddress3); WordDoc.Variables.Add('Address4', tAddress4); WordDoc.Variables.Add('Postcode', tPostcode); etc and error no document WordDoc.Fields.Update; I then have a custom menu in the toolbar in the document these values are being passed to, and all the menu items invoke this macro: Sub InsertData() Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldDocVariable, Text:= _ Application.CommandBars.ActionControl.Caption, PreserveFormatting:=True End Sub However! If, for examples sake, the address is 3 lines long (and so tAddress4 is a null value) when the user clicks on Address4 in the Word custom menu, he will get "Error! No document variable supplied." I would prefer for nothing to happen. For the click to be ignored so nothing appears on screen. Or, if need be, an empty field that displays nothing. Does this make any sense? Thanks. Levski MOS MASTER05-08-2005, 06:56 AMHi Lev, :D I'm trying to reproduce your error wich makes sence but I'm having a hard time...maybe it's version specifc mine is (2003) But as I understand if correct: You're inserting the caption of the commandbarbutton to create a fieldcode that c
Guest I've created a template with several user forms and numerous docvariable fields in the document corresponding to text boxes on the user forms. When I create a new document based on this template, the "Error! No document variable supplied." message appears as soon as the document is created (before any data is entered into the user forms). How do I prevent this error message from appearing in every Docvariable field in the document before the user forms are completed? dickens1228, Apr 2, 2009 #1 Advertisements Doug Robbins - Word MVP on news.microsoft.com Guest Open the template and run a macro containing the following code and then save and close the template Dim i As Long With ActiveDocument For i = 1 To .Variables.Count .Variables(i).Value = " " Next i End With -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "dickens1228" <> wrote in message news:... > I've created a template with several user forms and numerous docvariable > fields in the document corresponding to text boxes on the user forms. > When I > create a new document based on this template, the "Error! No document > variable supplied." message appears as soon as the document is created > (before any data is entered into the user forms). How do I prevent this > error message from appearing in every Docvariable field in the document > before the user forms are completed? Doug Robbins - Word MVP on news.microsoft.com, Apr 2, 2009 #2 Advertisements dickens1228 Guest Unfortunately, your suggestion didn't work. When I place my cursor over the "i" in the macro, it says "i = 4" which I think means it is not counting my DOCVARIABLE fields (I think it's only count