繁体   English   中英

如何在Visio中为批处理“适合绘图”编写宏?

[英]How can I write a macro for batch “fit to drawing” operation in Visio?

我需要首先通过应用“适合绘图”选项来保存所有visio文件,然后将它们另存为PDF文件。 但是我对宏不是很熟悉。 有人可以帮我吗?

我的文件夹结构是这样的:

  • 包含visio文件的文件夹
    • Visio文件
    • Visio文件
  • 包含visio文件的文件夹
    • Visio文件

最后,我需要为每个visio文件提供一个pdf文件,所有图表均应适合图纸。 我使用Visio 2013。

希望这段代码能对您有所帮助!

Sub Macro1()
Dim fso As Object, m_fld As Object, fld As Object, vd As Object, mf As String
Dim pdfn As String
Set fso = CreateObject("Scripting.FileSystemObject")
mf = InputBox("Path")
Set m_fld = fso.getfolder(mf)
For Each fld In m_fld.subfolders
    For Each fil In fld.Files
    If InStr(fil.Name, ".vsd") > 0 Then fit (fil.Path) ' MsgBox fil.Name
    Next
Next
For Each fil In m_fld.Files
    If InStr(fil.Name, ".vsd") > 0 Then fit (fil.Path)
Next
End Sub
Sub fit(fn As String)
Dim fd As Document
Set fd = Documents.OpenEx(fn, visOpenRW)
pdfn = Replace(fd.FullName, Right(fd.FullName, Len(fd.FullName) - InStrRev(fd.FullName, ".")), "pdf")
For Each pg In fd.Pages
    fd.Application.ActiveWindow.Page = pg.Name
    Application.ActiveWindow.ViewFit = visFitPage
Next
fd.ExportAsFixedFormat visFixedFormatPDF, pdfn, visDocExIntentScreen, visPrintAll
fd.Save
fd.Close
End Sub

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM