Bonjour à tous,

J'ai découvert la programmation VBA sous Visio il y a 1 semaine et jusque là j'arrivais à m'en sortir seul, mais je crois que j'ai atteints quelques limites. Je me retrouve face à un problème qui me bloque complètement, j'explique ma situation :

Tout d'abord, il faut savoir que j'utilise des données rentrées dans un tableau excel pour tracer des formes sous Visio, j'ai donc activer les références visio sous Excel.

A partir de l'appui d'un bouton sous Excel, je lance l'ouverture de visio, crée un document et une page par la méthode suivante :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Dim app_visio As Visio.Application
Dim doc_visio As Visio.Document
Dim vsoPage1 As Visio.Page
Dim vsoShape1 As Visio.Shape
'Création de l'objet application visio
Set app_visio = CreateObject("Visio.Application")
'Choix visualisation ou non du document
app_visio.Visible = True
app_visio.Application.ScreenUpdating = False
'Ouverture de Visio
Set doc_visio = app_visio.Application.Documents.AddEx("", visMSDefault, 0)
'Choix du mode paysage
app_visio.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageDrawSizeType).FormulaU = "3"
app_visio.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPrintProperties, visPrintPropertiesPageOrientation).FormulaU = "2"
'Choix de l'échelle 1:100
app_visio.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageWidth).FormulaU = "29.7 m"
app_visio.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageHeight).FormulaU = "21 m"
app_visio.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageScale).FormulaU = "1 cm"
app_visio.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageDrawingScale).FormulaU = "1 m"
app_visio.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageDrawScaleType).FormulaU = "4"
app_visio.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOLineToNodeX).FormulaForceU = "0.25 m"
app_visio.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOLineToNodeY).FormulaForceU = "0.25 m"
app_visio.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOBlockSizeX).FormulaForceU = "0.5 m"
app_visio.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOBlockSizeY).FormulaForceU = "0.5 m"
app_visio.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOAvenueSizeX).FormulaForceU = "0.75 m"
app_visio.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOAvenueSizeY).FormulaForceU = "0.75 m"
app_visio.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOLineToLineX).FormulaForceU = "0.25 m"
app_visio.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOLineToLineY).FormulaForceU = "0.25 m"
A partir de là, j'essaye d'ajouter via vba une feuille d'arrière plan, et c'est là que ça bloque. En effet, j'essaye d'insérer un gabarit automatiquement dans cet arrière plan, mais en utilisant l'enregisteur de macro et en exploitant le résultat,je n'arrive pas à le faire tourner sous Excel, j'ai le message "identificateur de fenêtre non valide".

Voici le bout de code qui ne fonctionne pas :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Set vsoPage1 = doc_visio.Pages.Add
vsoPage1.Name = "Arrière-plan-2"
vsoPage1.Background = True
vsoPage1.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageWidth).FormulaU = "14.85 m"
vsoPage1.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageHeight).FormulaU = "10.5 m"
vsoPage1.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageScale).FormulaU = "2 cm"
vsoPage1.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageDrawingScale).FormulaU = "1 m"
vsoPage1.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageDrawSizeType).FormulaU = "3"
vsoPage1.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageDrawScaleType).FormulaU = "4"
vsoPage1.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOLineToNodeX).FormulaForceU = "0.125 m"
vsoPage1.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOLineToNodeY).FormulaForceU = "0.125 m"
vsoPage1.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOBlockSizeX).FormulaForceU = "0.25 m"
vsoPage1.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOBlockSizeY).FormulaForceU = "0.25 m"
vsoPage1.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOAvenueSizeX).FormulaForceU = "0.375 m"
vsoPage1.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOAvenueSizeY).FormulaForceU = "0.375 m"
vsoPage1.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOLineToLineX).FormulaForceU = "0.125 m"
vsoPage1.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOLineToLineY).FormulaForceU = "0.125 m"
vsoPage1.PageSheet.CellsSRC(visSectionObject, visRowPageLayout, visPLOSplit).FormulaForceU = "1"
vsoPage1.PageSheet.CellsSRC(visSectionObject, visRowPrintProperties, visPrintPropertiesPageOrientation).FormulaU = "2"
vsoPage1.PageSheet.CellsSRC(visSectionUser, 0, visUserValue).FormulaForceU = ""
 
app_visio.Application.Windows.ItemEx("Dessin1").Activate
app_visio.Application.ActiveWindow.Page.Drop app_visio.Application.Documents.Item("MAP3D_M.VSS").Masters.ItemU("Car 1"), 237.598425, 186.023622
La dernière ligne est celle qui me pose problème, si quelqu'un pouvais m'aider à débloquer ma situation je serais très reconnaissant !