如何将多个visio文件(.vsd)转换为png

时间:2012-11-16 09:00:37

标签: command-line batch-file automation converter visio

我有很多Visio文件,并希望以编程方式将它们全部转换为png格式。

我找到了几个解决方案,但无法让它们起作用。

如何通过命令行或类似手段轻松将.vsd文件批量转换为.png?

1 个答案:

答案 0 :(得分:2)

使用内置的Visual Basic

类似这样的事情:自己修复路径部分。

Sub a()

   Dim docs As New Collection
   ' add the paths of your documents here, use more script if you want wildcard etc
   docs.Add ("C:\Users\[username]\Desktop\New folder (4)\drawing2.vsd")
   docs.Add ("C:\Users\[username]\Desktop\New folder (4)\drawing3.vsd")

   For Each d In docs    
      Dim doc As Document     
      Set doc = Documents.Add(d)

      Dim p As Page

        For Each p In doc.Pages       
        Dim n As String

        ' change this for the output path and format of your choice      
        n = "C:\Users\[username]\Desktop\New folder (4)\" & doc.Name & " " & p.Index & ".png"      
        p.Export (n)

        Next
    Next

End sub