none
Macro for repair one of reasons of Visio Error #318 RRS feed

  • Question

  • Please test my macro for repair Visio Error #318
     

    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  
    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


    Wait for yours advices



    Tuesday, June 10, 2014 11:51 AM

Answers

  • I modified this macro

    Sub vsd_RepairError318()
    Dim cl As Row, ss As Window
    Dim n As Integer
    n = 0
    Dim row_name$, row_value$, row_prompt$, new_prompt$, bl As Boolean
    Set ss = Application.ActiveDocument.DocumentSheet.OpenSheetWindow
    For i = ss.Shape.RowCount(242) - 1 To 0 Step -1
        row_name = Application.ActiveWindow.Shape.CellsSRC(visSectionUser, i, visUserValue).RowNameU
        row_formula = Application.ActiveWindow.Shape.CellsSRC(visSectionUser, i, visUserValue).FormulaU
        row_value = Application.ActiveWindow.Shape.CellsSRC(visSectionUser, i, visUserValue).ResultStr("")
        row_prompt = Application.ActiveWindow.Shape.CellsSRC(visSectionUser, i, visUserPrompt).FormulaU
        bl = InStr(row_formula, Trim("Pages["))
     If bl = True Then '
     n = n + 1
     If n = 1 Then new_prompt = "setf(getref(thedoc!user." & row_name & "), " & Chr(34) & Chr(34) & Chr(34) & row_value & Chr(34) & Chr(34) & Chr(34) & ")"
     If n > 1 Then new_prompt = new_prompt & "+setf(getref(thedoc!user." & row_name & "), " & Chr(34) & Chr(34) & Chr(34) & row_value & Chr(34) & Chr(34) & Chr(34) & ")"
     Else
     End If
    Next
    Debug.Print new_prompt
    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
    ss.Close
    End Sub

    • Marked as answer by SurrogateMVP Friday, April 3, 2015 7:53 AM
    Friday, September 26, 2014 12:37 PM

All replies

  • Hi,

    This is the forum to discuss questions and feedback for Microsoft Office, I'll move your question to the MSDN forum for General Office Development

    http://social.msdn.microsoft.com/Forums/en-US/home?forum=officegeneral&filter=alltypes&sort=lastpostdesc

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    George Zhao
    TechNet Community Support



    Wednesday, June 11, 2014 4:50 AM
  • Did you try to debug the code? What line of code generates the error?
    Wednesday, June 11, 2014 11:43 AM
  • my code really repair only one of causes of Error #318: The cell in the Document Shapesheet has a reference to another cell in the some Page Shapesheet. 

    Error #318

    I often get files with this error from my collegues. Few years ago i create files with Error #318, then i add to cells in DocumentSheet references like Pages[Page-33]!Sheet.1!Prop.row_1  

    Now I repair received files with this code, and don't generate this error myself :)

    All causes of this error you can find in article Error #318 Explained and in comments.

     



    • Edited by SurrogateMVP Monday, March 25, 2019 1:35 PM Fix broken hyperlink
    Monday, June 16, 2014 10:36 AM
  • I modified this macro

    Sub vsd_RepairError318()
    Dim cl As Row, ss As Window
    Dim n As Integer
    n = 0
    Dim row_name$, row_value$, row_prompt$, new_prompt$, bl As Boolean
    Set ss = Application.ActiveDocument.DocumentSheet.OpenSheetWindow
    For i = ss.Shape.RowCount(242) - 1 To 0 Step -1
        row_name = Application.ActiveWindow.Shape.CellsSRC(visSectionUser, i, visUserValue).RowNameU
        row_formula = Application.ActiveWindow.Shape.CellsSRC(visSectionUser, i, visUserValue).FormulaU
        row_value = Application.ActiveWindow.Shape.CellsSRC(visSectionUser, i, visUserValue).ResultStr("")
        row_prompt = Application.ActiveWindow.Shape.CellsSRC(visSectionUser, i, visUserPrompt).FormulaU
        bl = InStr(row_formula, Trim("Pages["))
     If bl = True Then '
     n = n + 1
     If n = 1 Then new_prompt = "setf(getref(thedoc!user." & row_name & "), " & Chr(34) & Chr(34) & Chr(34) & row_value & Chr(34) & Chr(34) & Chr(34) & ")"
     If n > 1 Then new_prompt = new_prompt & "+setf(getref(thedoc!user." & row_name & "), " & Chr(34) & Chr(34) & Chr(34) & row_value & Chr(34) & Chr(34) & Chr(34) & ")"
     Else
     End If
    Next
    Debug.Print new_prompt
    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
    ss.Close
    End Sub

    • Marked as answer by SurrogateMVP Friday, April 3, 2015 7:53 AM
    Friday, September 26, 2014 12:37 PM