Visio Insights
The official blog of the Microsoft Visio product team

Error #318 Explained

Error #318 Explained

  • Comments 16

Every once in a while we hear from a user who has encountered a cryptic error message in Visio and is left helpless.  Most of Visio’s error messages are somewhat explanatory, though we continue to improve their wording.  However, there is another set of messages that report “internal errors”. 

 

Internal errors are usually problems where the Visio program has done something wrong, whereas other errors are shown in response to things the user has done.  Internal errors can be identified by an error number included within the message text.  Often the message provides no clue as to the problem or possible remedies.  We’ll look at one of the more frequently encountered internal error messages in this post – Error #318.

 

Error #318 can occur when you copy and paste a shape from one document to another.  There are some specific circumstances needed to trigger the error:

  • The shape is an instance of a master
  • The shape has a reference to a cell in the Document Shapesheet
  • The cell in the Document Shapesheet has a reference to another cell in the Document Shapesheet
  • The Document Shapesheet cells are not present in the target document

This is not the only way to encounter this error, but it is representative of what can happen.  Here are the steps to reproduce the problem:

 

  • Create a new blank Visio drawing
  • Open the Drawing Explorer from the View menu
  • Open the Document Shapesheet by right-clicking on the top item in the explorer
  • Create two rows in the User-defined section named Test1 and Test2
  • For the value of User.Test1, enter =User.Test2
  • Close the Document Shapesheet window

 

 

  • Right-click on the Masters item in the Drawing Explorer and choose New Master
  • Enter the name Test for the master and click OK
  • Edit the Test master and draw a rectangle
  • Open the Shapesheet for the rectangle and create a row in the User-defined section name Test
  • For the value of User.Test enter =TheDoc!User.Test1
  • Close the Shapesheet and master edit windows and accept changes

 

  • Go File > Shapes > Show Document Stencil
  • Drag and drop the Test master onto the page
  • Copy and Paste the shape into a new blank document

The problem for Visio is the secondary reference in the Document Shapesheet to another cell.  Normally when a shape moves between documents, Visio automatically copies over the page and document cells that the shape depends on – creating them if necessary.  Visio sees that the shape being copied has a reference to cell User.Test1 in the Document Shapesheet, and it creates this cell in the target document.  Visio does not know that the contents of cell User.Test1 themselves have a reference to another cell.  Cell User.Test2 is not created in the target document.  When Visio tries to complete the Paste operation and recalculates the cells, it finds that there is a missing reference.  Error #318 is shown and the Paste operation fails.

 

Unfortunately this is no simple bug in Visio but a significant architectural limitation, which means that a fix for the problem is not forthcoming.  However, by understanding how this error can occur we can identify some remedies.  In order for the Paste operation to succeed, the target document must have the correct set of Document Shapesheet cells in place.  It is certainly possible to add the required cells prior to doing the Paste.  Another option is to make sure the shape has a direct reference to each of the Document Shapesheet cells itself.  This might be a solution for shape and solution designers to use so that their users don’t experience strange Copy / Paste failures.

 

If you encounter internal Visio errors, please tell us about it.  We’ll try to explain a few other common ones in a future post.

 

 

Leave a Comment
  • Please add 7 and 5 and type the answer here:
  • Post
  • PingBack from http://microsoft.wagalulu.com/2006/07/14/error-318-explained/
  • Thanks for this -- in a curious bit of timing I had scanned the article a couple of days ago. And then today a customer of our Visio add-in called to say she was getting an error 318 when attempting to copy one of our shapes.

    I recalled this posting, read the very complete explanation and knew exactly what to look for in the shapesheet.

    Thanks for anticipating my need!

    Scott
  • We have been seeing this message OFTEN, and I believe that it has something to do with the conversion of a Visio 2002 file to Visio 2003.  (We have clients still on 2002, and certainly many documents originally created on 2002.)  

    The shapesheets themselves seem messed up... They are now referring to document shapesheet cells (that don't exist), while they had referred to other cells (within the shape) before.  It appears as though the shapesheet cell names have changed between versions (e.g. "Controls.Row_1.X" now, versus "Controls.X1" before).  Could this have caused compatibility problems?

    Are there any known issues for this?  

  • More information (from the previous comment), for anyone interested.  We had old stencils (Visio 2000) that just seemed to be horribly corrupted in Visio 2003.  As it turns out, the RowNameU and RowName properties were different for some of the shapes.  That may have dated back to pre-Visio 2000 days.  I think that Visio 2003 displays RowNameU, which is different behavior than previous versions.  When Visio 2003 tried to save those shapes (even if they were untouched) in a stencil, things got screwed up, and the formulas started referring to non-existent cells, eventually resulting in the 318 errors.  Sigh.
  • Thanks for the follow-up, Jeffrey.  You are correct that Visio 2003 displays RowNameU in the Shapesheet window.  If you want to send us a drawing that reproduces the problem just use the e-mail link at the top of the page.

    Mark Nelson
  • What a dumb ass article.  This is clearly a serious bug in Visio and MicroSoft just walks away from the problem with "no fix" option.

    The explainations refer to things like "Drawing Explorer" but when I click on the "View" tab, nothing is named "Drawing Explorer" and I'm left stuck with a drawing that can't be used.  I guess the real solution is to dump Microsoft and use something better.  This is way to expensive a piece of software to have this kind of issue and no fix to be provided.

  • These are "instructions"??  You have to be kidding me!!!

  • that occurs then there are object in visio on which Function set to value and function is not exists (horizontal panel). So just check the Function value for each object in ShapeData  window

  • The article was posted in 2006, but I'm using Visio 2010 and still have this problem. It's incredibly frustrating that Microsoft hasn't resolved this maddening issue. My visio files are useless if I cannot copy/paste them as images. Very disappointed at no fix.

  • I just followed these instructions.  Difficult to follow given that in Visio 2010 cell references cannot use a . (period), and other little inconsistencies like that.  However, I persevered.  Which has left me with ?????   How is this fixing the problem with my document?

  • I have had this error due to a broken reference to a master shape. The shape I created was not fully ungrouped before I started to modify it. Later I changed the master shape, erasing something from it, particularly a part that was referenced in the new shape. So when trying to ungroup the new shape completely, Visio complained. Conclusion: before making new shapes, always make sure they're not connected to master shapes anymore and ungroup completely.

  • This is a crazy flaw that still drives Visio users crazy! Amazing that you can get an error just trying to copy! Please fix this Microsoft!  

  • I just came across this error whilst trying to copy pages from a number of visio files into one.

    Managed to resolve this by selecting each object type individually and trying to copy to identify the shape causing the problem.

    Then once identified, i just dragged that shape from the stencil onto the page, deleted the shape iadded and can now copy the original shapes no problem. Only had to do this to one of the open files but can copy from all the open files, since doing the above.

    The shapes and stencils however are some we have been using for two years and never had the issue before - weird

  • try my macro it changed in DocumentSheet user-defined cells which contained formula like Pages[Page-1]!sheet.1!user.row_1 according value

    Sub vsd_RepairError318()

    Dim cl As Row

    Dim n As Integer

    n = 0

    Dim row_name$, row_value$, row_prompt$, new_prompt$, bl As Boolean

    For i = ActiveWindow.Shape.RowCount(242) - 1 To 0 Step -1

       row_name = Application.ActiveWindow.Shape.CellsSRC(visSectionUser, i, visUserValue).RowNameU

       row_value = Application.ActiveWindow.Shape.CellsSRC(visSectionUser, i, visUserValue).FormulaU

       row_prompt = Application.ActiveWindow.Shape.CellsSRC(visSectionUser, i, visUserPrompt).FormulaU

       Debug.Print Mid(row_value, 2, 6), Left(row_value, 6)

       bl = InStr(row_value, Trim("Pages["))

    If bl = True Then '

    n = n + 1

    If n = 1 Then new_prompt = "setf(getref(user." & row_name & "), " & row_value & ")"

    If n > 1 Then new_prompt = new_prompt & "+setf(getref(user." & row_name & "), " & row_value & ")"

    Else

    End If

    Next

    ActiveDocument.DocumentSheet.AddNamedRow visSectionUser, "Err318fix", visTagDefault

    ActiveDocument.DocumentSheet.Cells("User.Err318fix.prompt").FormulaU = new_prompt

    Application.ActiveWindow.Shape.DeleteRow visSectionUser, ActiveWindow.Shape.RowCount(242) - 1

    End Sub

  • Hi

    I had the same problem. Select all and right click to choose "Bring to Front". This will solve the problem.

    Thanks

Page 1 of 2 (16 items) 12