Hi
you're getting the dialog box because you're asking for it here
Set ViewEdit = app.CommandManager.ControlDefinitions("DrawingViewEditCtxCmd")
'other code
ViewEdit.Execute2 True
Also, you are setting the ViewRepresentation to do something if the value is ""
Representation = oDrawView.ActiveDesignViewRepresentation
If Representation = "" Then
at worst, the ViewRep would be Master. You cannot set association with a Master view rep. In this code below, it checks for the document type and only executes if its an assembly. Then it sets the DesignViewRep to "Default" (which is one i made up to test the code so you should change Default to your own)
The code line
oDrawView.SetDesignViewRepresentation("Default", True)
is setting the viewrep to the currently active drawing view to the view rep you want and setting the association to True.
Dim app As Application: Set app = ThisApplication
Dim oDrawDoc As DrawingDocument: Set oDrawDoc = app.ActiveDocument
Dim oSheet As Sheet
For Each oSheet In oDrawDoc.Sheets
Dim oDrawView As DrawingView
For Each oDrawView In oSheet.DrawingViews
If oDrawView.ReferencedDocumentDescriptor.ReferencedDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
Dim Rep As DesignViewRepresentation = oDrawView.ActiveDesignViewRepresentation
oDrawView.SetDesignViewRepresentation("Default", True)
End If
Next
Next
let me know if this works for you and i can help you out
Thx
Nacho
Automation & Design Engineer
Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.