Visio录制宏,重复批量导出600dpi的tiff图片
因为论文修改需要,需要对 3 × 3 × 4 = 36 3\times3\times4=36 3×3×4=36张图片反复修改调整,然后将图片依次导出为600dpi的tiff图片。很不幸的是,枯燥的导出动作做了五六遍,郁闷时想到之前了解过的宏,宏可以把动作转换成代码实现
,是进行重复枯燥操作工作者的福音。实际上,在word/ppt/excel等软件中枯燥的重复操作,都可考虑用宏实现。
用代码可以解放一切反人类的重复枯燥动作。
不同软件里找到宏的方法,在下述软件里,一些重复操作动作,都可考虑宏实现。
- word/excel/PPT 视图>宏
(在word/PPT里,更常见的操作是按F4,以重复上一次的操作)
- visio 开发工具>宏
用Visio导出三张600dpi的tiff图片的宏代码如下:
Sub Macro3()'Enable diagram servicesDim DiagramServices As IntegerDiagramServices = ActiveDocument.DiagramServicesEnabledActiveDocument.DiagramServicesEnabled = visServiceVersion140 + visServiceVersion150 %当前范围声明,仅需一次Application.Settings.SetRasterExportResolution visRasterUseCustomResolution, 600#, 600#, visRasterPixelsPerInchApplication.Settings.SetRasterExportSize visRasterFitToSourceSize, 3.4375, 1.8125, visRasterInchApplication.Settings.RasterExportDataCompression = visRasterNoneApplication.Settings.RasterExportColorReduction = visRasterAdaptiveApplication.Settings.RasterExportColorFormat = visRaster24BitApplication.Settings.RasterExportRotation = visRasterNoRotationApplication.Settings.RasterExportFlip = visRasterNoFlipApplication.Settings.RasterExportBackgroundColor = 16777215ActiveWindow.DeselectAllActiveWindow.Select Application.ActiveWindow.Page.Shapes.ItemFromID(1074), visSelect %ID可从形状名>ID处获取值Application.ActiveWindow.Selection.Export "D:picture\no_load_all_源文件-501.tif" %导出路径及命名Application.Window.WindowState = visWSRestored'Restore diagram servicesActiveDocument.DiagramServicesEnabled = DiagramServicesApplication.Settings.SetRasterExportResolution visRasterUseCustomResolution, 600#, 600#, visRasterPixelsPerInchApplication.Settings.SetRasterExportSize visRasterFitToSourceSize, 3.4375, 1.8125, visRasterInchApplication.Settings.RasterExportDataCompression = visRasterNoneApplication.Settings.RasterExportColorReduction = visRasterAdaptiveApplication.Settings.RasterExportColorFormat = visRaster24BitApplication.Settings.RasterExportRotation = visRasterNoRotationApplication.Settings.RasterExportFlip = visRasterNoFlipApplication.Settings.RasterExportBackgroundColor = 16777215ActiveWindow.DeselectAllActiveWindow.Select Application.ActiveWindow.Page.Shapes.ItemFromID(1075), visSelectApplication.ActiveWindow.Selection.Export "D:picture\no_load_all_源文件-502.tif"Application.Window.WindowState = visWSRestored'Restore diagram servicesActiveDocument.DiagramServicesEnabled = DiagramServicesApplication.Settings.SetRasterExportResolution visRasterUseCustomResolution, 600#, 600#, visRasterPixelsPerInchApplication.Settings.SetRasterExportSize visRasterFitToSourceSize, 3.4375, 1.8125, visRasterInchApplication.Settings.RasterExportDataCompression = visRasterNoneApplication.Settings.RasterExportColorReduction = visRasterAdaptiveApplication.Settings.RasterExportColorFormat = visRaster24BitApplication.Settings.RasterExportRotation = visRasterNoRotationApplication.Settings.RasterExportFlip = visRasterNoFlipApplication.Settings.RasterExportBackgroundColor = 16777215ActiveWindow.DeselectAllActiveWindow.Select Application.ActiveWindow.Page.Shapes.ItemFromID(1075), visSelectApplication.ActiveWindow.Selection.Export "D:picture\no_load_all_源文件-503.tif"Application.Window.WindowState = visWSRestored'Restore diagram servicesActiveDocument.DiagramServicesEnabled = DiagramServicesEnd Sub
获取上述宏代码也很简单,找到宏,点击录制,进行需要录制的操作,操作完成后,点击停止录制,即可获得宏代码。以上述代码为例,第二段、第三段代码是复制第一段代码变化来的,删除重复声明,修改ID值,修改导出的文件名。