Hi @Rex Lau ,
You can use Microsoft.Office.Interop.Visio Namespace.
Check if the following code works for you.
Imports Microsoft.Office.Interop.Visio
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim processor As New VisioProcessor()
processor.ProcessVisioFiles("C:\YourFolderPath")
End Sub
Public Sub ProcessVisioFiles(folderPath As String)
Dim visioApp As New Application()
visioApp.Visible = False
Dim files As String() = IO.Directory.GetFiles(folderPath, "*.vsd*", IO.SearchOption.TopDirectoryOnly)
For Each filePath As String In files
Dim doc As Document = visioApp.Documents.Open(filePath)
Console.WriteLine("File: " & filePath)
For Each page As Page In doc.Pages
Console.WriteLine("Page Name: " & page.Name)
Dim shapesCount As Integer = page.Shapes.Count
Console.WriteLine("Number of Shapes: " & shapesCount)
Next
doc.Close()
Next
visioApp.Quit()
End Sub
End Class
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.