Visio Shape Datas to Excel

Started by longo93, June 20, 2016, 12:28:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

longo93

Hello,

i want to give my self defined shape datas from visio in an excel file. Therefore i have the following code ...

Sub DatenSchreiben()
Dim appExcel As Excel.Application
Dim mappe As Excel.Workbook
Dim blatt As Excel.Worksheet
Dim zelle As Excel.Range
Dim shp As Visio.Shape
Dim i As Integer

Set appExcel = Excel.Application
appExcel.Visible = True
Set mappe = appExcel.Workbooks.Open(FileName:="Test")
Set blatt = mappe.ActiveSheet

i = 1
blatt.Cells(i, 1).Value = "Positionsnummer"
blatt.Cells(i, 2).Value = "Name"
blatt.Cells(i, 3).Value = "Typ"
blatt.Cells(i, 4).Value = "Anzahl"

For Each shp In ActivePage.Shapes
If shp.CellExists("Prop.NameDE", True) Then
i = i + 1
blatt.Cells(i, 1).Value = shp.Cells("prop.ShapeNumber").Formula
blatt.Cells(i, 2).Value = shp.Cells("prop.NameDE").ResultStr("")
blatt.Cells(i, 3).Value = shp.Cells("prop.Typ").Formula
End If
Next shp

End Sub



It´s working pretty well, i can open an excel file from visio and i get the headlines for the table which i defined. But its not working to fill the excel cells with the shape data. Do u have any idea what is my problem ?


metuemre

Can you please replace

If shp.CellExists("Prop.NameDE", True) Then

with

If shp.CellExists("Prop.NameDE", Visio.visExistsAnywhere) <> 0 Then

and try again

wapperdude

#2
Try  CellExistsU.

But, I Vaguely remember a problem with that syntax, and ended up :  If Not shp.CellExistsU("Prop.NameDE", False) Then

Seems odd, but the double negative works.

Wapperdude
Visio 2019 Pro

longo93

Thanks for your help, i just deleted the if row and now its working pretty good :)