-
Notifications
You must be signed in to change notification settings - Fork 5
/
Program.cs
54 lines (48 loc) · 1.94 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
namespace VisioExportPagesToDocs
{
internal class Program
{
private static void Main(string[] args)
{
if (args.Length < 1)
{
System.Console.WriteLine("Syntax is: VisioExportPagesToDocs <filename.vsd> [<outptufolder>]");
System.Environment.Exit(0);
}
string input_filename = args[0];
input_filename = System.IO.Path.GetFullPath(input_filename);
var visioapp = new Microsoft.Office.Interop.Visio.Application();
var docs = visioapp.Documents;
Microsoft.Office.Interop.Visio.Document doc = null;
try
{
doc = docs.Open(input_filename);
var settings = new ExporterSettings();
settings.InputDocument = doc;
if (args.Length >= 2)
{
settings.DestinationPath = args[1];
}
else
{
settings.DestinationPath = System.IO.Path.GetDirectoryName(input_filename);
}
var exporter = new Exporter(settings);
foreach (var rec in exporter.Run())
{
Console.WriteLine();
Console.WriteLine("Page Index: {0}", rec.PageIndex);
Console.WriteLine("Page Name: {0}", rec.PageName);
Console.WriteLine("Output document: {0}", rec.OutputFilename);
Console.WriteLine("Output document already exists: {0}", rec.OutputFileAlreadyExists);
Console.WriteLine("Wrote output document: {0}", rec.OutputFileWritten);
}
}
catch (System.Runtime.InteropServices.COMException comexc)
{
throw new System.ArgumentException(string.Format("Failed to open file: {0}", comexc.Message));
}
}
}
}