Changement de forme Visio automatique avec Excel

Bonjour,

je suis actuellement en train de créer une macro pour modifier de manière automatique des formes visio avec un nouveau gabarit.

J'ai créé une toute petite partie pour faire un essai. Cependant, j'ai des soucis ActiveX. Si une personne peut m'aider svp.

Voici mon code:

Public Sub vso()

Dim MonApplication As Object
Dim MonFichier As String
Dim shpObjs As Visio.Shapes
Dim shpObj As Visio.Shape
Dim celObj As Visio.Cell
Dim PagObj As Visio.Page
Dim visShp As Visio.Shape
Dim visShps As Visio.Shapes
Dim a As String
Dim b As String

Set MonApplication = CreateObject("Shell.Application")

MonFichier = "Path.vsd" 'choix du fichier
MonApplication.Open (MonFichier)

For Each PagObj In ActiveDocument.Pages
For Each visShp In PagObj.Shapes
a = "Ana Sens"
b = "Threshold min"
Select Case visShp.Name
Case "Instr(visShp.Name, a)<>0"
visShp.ReplaceShape Application.Documents.Item("Path.vssx").Masters.ItemU("ANA Sens")
Case "Instr(visShp.Name, b)<>0"
visShp.ReplaceShape Application.Documents.Item("Path.vssx").Masters.ItemU("Threshold min")
Case Else
MsgBox (NomForme)
End Select
Next visShp
Next PagObj

End Sub

J'obtiens comme erreur : "Erreur 429": Un composant ActiveX ne peut pas créer d'objet.

En débogage, c'est la ligne " For Each PagObj In ActiveDocument.Pages" qui pose problème

Bon, j'ai trouvé. Il faut que je code directement dans Visio :)

Rechercher des sujets similaires à "changement forme visio automatique"