+ Reply to Thread
Results 1 to 3 of 3

Avoid "Error! No document variable supplied"

  1. #1
    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 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???

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    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

  3. #3
    Registered User
    Join Date
    11-25-2011
    Location
    Lilydale, Victoria, Australia
    MS-Off Ver
    2013 (365)
    Posts
    63

    Red face Re: Avoid "Error! No document variable supplied"

    Thanks for the suggestion, JosephP. While I was trying to figure out how I might do that, I discovered that the method of putting in a " " was OK - it didn't work when I first tried it because I had been overwriting the " " with "". My bad!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1