Exemple #1
0
        private static int Import(ImportOptions opt)
        {
            var app = new Visio.InvisibleApp();

            var settings = new Settings
            {
                ClearBeforeImport = opt.ClearBeforeImport,
                IncludeStencils   = opt.IncludeStencils
            };

            foreach (var inputFile in opt.InputFiles)
            {
                var inputFilePath = Path.IsPathRooted(inputFile)
                    ? inputFile
                    : Path.Combine(Environment.CurrentDirectory, inputFile);

                var doc = app.Documents.OpenEx(inputFilePath,
                                               (short)Visio.VisOpenSaveArgs.visOpenRW | (short)Visio.VisOpenSaveArgs.visOpenMacrosDisabled);

                var path = string.IsNullOrEmpty(opt.InputDirectory)
                    ? Environment.CurrentDirectory
                    : Path.IsPathRooted(opt.InputDirectory)
                    ? opt.InputDirectory
                    : Path.Combine(Environment.CurrentDirectory, opt.InputDirectory);

                VisioVBA.ImportVBA(doc, path, settings, true);

                doc.Close();
            }

            app.Quit();
            return(0);
        }
Exemple #2
0
        private static int Export(ExportOptions opt)
        {
            var app = new Visio.InvisibleApp();

            var settings = new Settings
            {
                IncludeStencils = opt.IncludeStencils
            };

            var inputFilePath = Path.IsPathRooted(opt.InputFile)
                ? opt.InputFile
                : Path.Combine(Environment.CurrentDirectory, opt.InputFile);

            var doc = app.Documents.OpenEx(inputFilePath,
                                           (short)Visio.VisOpenSaveArgs.visOpenCopy | (short)Visio.VisOpenSaveArgs.visOpenRO | (short)Visio.VisOpenSaveArgs.visOpenMacrosDisabled);

            var path = string.IsNullOrEmpty(opt.OutputDirectory)
                ? Environment.CurrentDirectory
                : Path.IsPathRooted(opt.OutputDirectory)
                ? opt.OutputDirectory
                : Path.Combine(Environment.CurrentDirectory, opt.OutputDirectory);

            VisioVBA.ExportVBA(doc, path, settings);

            app.Quit();
            return(0);
        }
Exemple #3
0
        public VisioDrawer()
        {
            //These variable allow Visio to run quickly, and quietly
            //Defer Recalc needs to be set to 0 after processing is done
            VisApp                         = new Visio.InvisibleApp();
            VisApp.UndoEnabled             = false;
            VisApp.LiveDynamics            = false;
            VisApp.AutoLayout              = false;
            VisApp.DeferRecalc             = -1;
            VisApp.DeferRelationshipRecalc = true;

            //Open the page holding the master collection so we can use it
            string executingSource = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string executingFolder = System.IO.Path.GetDirectoryName(executingSource);

            //Add a new document - this becomes the active document
            //if we do not do this, we get throw an exception
            VisApp.Documents.Add(executingFolder + "\\Config\\VisioTemplate.vsd");


            MastersDocuments = VisApp.Documents;
            MasterDoc        = MastersDocuments.OpenEx(executingFolder + "\\Config\\Stencil.vss", (short)Visio.VisOpenSaveArgs.visOpenHidden);

            //Now get a masters collection to use
            Masters = MasterDoc.Masters;

            //now get the active document
            ActiveDoc = VisApp.ActiveDocument;

            connectionMaster = GetMaster(@"Arrow");
            missingJobMaster = GetMaster(@"External Job");
            fullShapeMaster  = GetMaster(@"FullShapeTemplate");
            containerMaster  = GetMaster(@"Container");
        }
Exemple #4
0
        public VisioGraph(ProgressWindow progressWindow, ProcessViewerDialog parent)
        {
            try
            {
                var drawItem = parent.Result;
                _vapp = new Visio.InvisibleApp();

                if (!IsCorrectVisioVersion(_vapp))
                    return;

                _progressWindow = progressWindow;

                _vdoc = _vapp.Documents.Add("");

                if (!File.Exists(_vapp.Path + @"1033\Concept.vss"))
                {
                    File.Delete(_vapp.Path + @"1033\Concept.vss");
                    File.WriteAllBytes(_vapp.Path + @"1033\Concept.vss", Properties.Resources.Concept);
                }

                _stencil = _vapp.Documents.OpenEx(_vapp.Path + @"1033\Concept.vss", (short)Visio.VisOpenSaveArgs.visOpenDocked | (short)Visio.VisOpenSaveArgs.visOpenRO | (short)Visio.VisOpenSaveArgs.visAddStencil);

                _vdoc.Pages[1].Name = "Overview Page";

                _parent = parent;

                _bgWorker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true };
                _bgWorker.DoWork += DoWork;
                _bgWorker.RunWorkerCompleted += RunWorkerCompleted;
                _bgWorker.ProgressChanged += ProgressChanged;

                _progressWindow.pbarTotal.Minimum = 0;

                int totalOperations = 0;
                foreach (var process in drawItem.Process)
                {
                    process.GenerateContent(drawItem.ConnectionString);
                    totalOperations += process.SubProcesses.Count();
                    totalOperations += process.Connectors.Count();
                }

                int stepSize = totalOperations / 20;

                _progressWindow.pbarTotal.Maximum = (totalOperations) + stepSize;

                var args = new WorkerArgs
                               {
                                   DrawItem = drawItem,
                                   StepSize = stepSize,
                               };

                _bgWorker.RunWorkerAsync(args);
            }
            catch (Exception)
            {
                MessageBox.Show(@"Unable to load Visio. Please make sure Visio 2010 has been installed on your system.");
            }
        }
Exemple #5
0
        public static new int Convert(String inputFile, String outputFile, Hashtable options)
        {
            Boolean running = (Boolean)options["noquit"];

            Microsoft.Office.Interop.Visio.InvisibleApp app = null;
            String tmpFile   = null;
            String extension = "vsd";

            try
            {
                try
                {
                    app = (Microsoft.Office.Interop.Visio.InvisibleApp)Marshal.GetActiveObject("Visio.Application");
                }
                catch (System.Exception)
                {
                    app     = new Microsoft.Office.Interop.Visio.InvisibleApp();
                    running = false;
                }
                Regex extReg = new Regex("\\.(\\w+)$");
                Match match  = extReg.Match(inputFile);
                if (match.Success)
                {
                    extension = match.Groups[1].Value;
                }

                // We can only convert svg, vsdx and vsdm files with Visio 2013
                if (System.Convert.ToDouble(app.Version.ToString()) < 15 &&
                    ((String.Compare(extension, "vsdx") == 0) ||
                     (String.Compare(extension, "vsdm") == 0) ||
                     (String.Compare(extension, "svg") == 0)))
                {
                    Console.WriteLine("File type not supported in Visio version {0}", app.Version);
                    return((int)ExitCode.UnsupportedFileFormat);
                }

                bool  pdfa  = (Boolean)options["pdfa"] ? true : false;
                short flags = 0;
                if ((Boolean)options["readonly"])
                {
                    flags += 2;
                }
                if (!(Boolean)options["hidden"])
                {
                    app.Visible = true;
                }
                VisDocExIntent quality = VisDocExIntent.visDocExIntentPrint;
                if ((Boolean)options["print"])
                {
                    quality = VisDocExIntent.visDocExIntentPrint;
                }
                if ((Boolean)options["screen"])
                {
                    quality = VisDocExIntent.visDocExIntentScreen;
                }
                Boolean includeProps = !(Boolean)options["excludeprops"];
                Boolean includeTags  = !(Boolean)options["excludetags"];

                var documents = app.Documents;
                Console.WriteLine("Opening file");
                documents.OpenEx(inputFile, flags);

                // Try and avoid dialogs about versions and convert SVG files to
                // visio to get ready for printing
                if (String.Compare(extension, "svg") == 0)
                {
                    extension = "vsd";
                }
                tmpFile = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + "." + extension;

                var activeDoc = app.ActiveDocument;
                activeDoc.SaveAs(tmpFile);
                activeDoc.ExportAsFixedFormat(VisFixedFormatTypes.visFixedFormatPDF, outputFile, quality, VisPrintOutRange.visPrintAll, 1, -1, false, true, includeProps, includeTags, pdfa);
                activeDoc.Close();

                Converter.ReleaseCOMObject(documents);
                Converter.ReleaseCOMObject(activeDoc);
                return((int)ExitCode.Success);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return((int)ExitCode.UnknownError);
            }
            finally
            {
                if (tmpFile != null)
                {
                    System.IO.File.Delete(tmpFile);
                }
                if (app != null && !running)
                {
                    app.Quit();
                }
                Converter.ReleaseCOMObject(app);
            }
        }
        public void GenerateVSS()
        {
            visapp         = new IVisio.InvisibleApp();
            visapp.Visible = false;
            foreach (fileListElement fileEl in fileList)
            {
                try
                {
                    string templateFileName = Directory.GetCurrentDirectory() + "\\template.vss";
                    string newFullfileName  = fileEl.filePath + "\\result\\" + fileEl.fileName.Replace(".kml", ".vsd");

                    if (!File.Exists(templateFileName))
                    {
                        throw new Exception("Не найден шаблон выходного файла: " + templateFileName);
                    }

                    Directory.CreateDirectory(fileEl.filePath + "\\result\\");

                    string fileName = fileEl.fileName;
                    string caption  = "Поопорная схема ВЛ 0,4 кВ от ";
                    string firstTmp = "";
                    int    tpPos    = fileName.IndexOf("ТП");
                    if (tpPos >= 0)
                    {
                        firstTmp = fileName.Substring(tpPos, fileName.Length - tpPos).Replace('_', '/').Replace(".kml", "");
                        string secondTmp = fileName.Substring(0, tpPos - 1);
                        fileName = firstTmp + " кВА " + secondTmp;
                    }
                    else
                    {
                        throw new Exception("Не корректное название файла: " + fileName);
                    }
                    caption = caption + fileName + " " + fileEl.city;

                    IVisio.Document doc  = visapp.Documents.Open(templateFileName);// (short)IVisio.VisOpenSaveArgs.visAddHidden + (short)IVisio.VisOpenSaveArgs.visOpenNoWorkspace);
                    IVisio.Page     page = doc.Pages[1];

                    IVisio.Shape visioRectMaster = page.Shapes.get_ItemU("Sheet.1");
                    visioRectMaster.Text = caption;

                    visioRectMaster      = page.Shapes.get_ItemU("Sheet.509");
                    visioRectMaster.Text = caption;

                    visioRectMaster      = page.Shapes.get_ItemU("Sheet.496");
                    visioRectMaster.Text = fileEl.make;

                    visioRectMaster      = page.Shapes.get_ItemU("Sheet.508");
                    visioRectMaster.Text = fileEl.makeDate;

                    visioRectMaster      = page.Shapes.get_ItemU("Sheet.495");
                    visioRectMaster.Text = fileEl.check;

                    visioRectMaster      = page.Shapes.get_ItemU("Sheet.507");
                    visioRectMaster.Text = fileEl.checkDate;

                    int    pos2 = firstTmp.LastIndexOf('-');
                    int    pos3 = firstTmp.LastIndexOf('/');
                    string tmp2 = "?";
                    if (pos2 != -1 & pos3 != -1 & pos3 > pos2)
                    {
                        tmp2 = firstTmp.Substring(pos2 + 1, pos3 - pos2 - 1);
                    }

                    visioRectMaster      = page.Shapes.get_ItemU("Sheet.314");
                    visioRectMaster.Text = "РЛНД - " + tmp2;

                    IVisio.Master aMaster;
                    switch (fileEl.tpType)
                    {
                    case "Столбовая":
                        aMaster         = doc.Masters.get_ItemU(@"СТП");
                        visioRectMaster = page.Drop(aMaster, 6.3400314961, 5.4108622047);
                        //visioRectMaster.tra
                        visioRectMaster.Shapes[2].Text = "С" + firstTmp;
                        break;

                    case "Мачтовая":
                        aMaster         = doc.Masters.get_ItemU(@"МТП");
                        visioRectMaster = page.Drop(aMaster, 6.3976378, 5.4108622047);
                        visioRectMaster.Shapes[2].Text = "М" + firstTmp;
                        break;

                    case "Закрытая":
                        aMaster         = doc.Masters.get_ItemU(@"ЗТП");
                        visioRectMaster = page.Drop(aMaster, 6.313976378, 5.23622);
                        visioRectMaster.Shapes[2].Text = "З" + firstTmp;
                        break;

                    case "Комплектная":
                        aMaster         = doc.Masters.get_ItemU(@"КТП");
                        visioRectMaster = page.Drop(aMaster, 6.4422795276, 5.4108622047);
                        visioRectMaster.Shapes[2].Text = "К" + firstTmp;
                        break;
                    }

                    doc.SaveAs(newFullfileName);
                    doc.Close();
                    //visapp.Quit();
                }
                catch (Exception ex)
                {
                    LogTextEvent(Color.Red, ex.Message);
                }
            }
            foreach (IVisio.Document aDoc in visapp.Documents)
            {
                aDoc.Close();
            }
            visapp.Quit();
        }
        public static new int Convert(String inputFile, String outputFile, Hashtable options)
        {
            Boolean running = (Boolean)options["noquit"];
            Microsoft.Office.Interop.Visio.InvisibleApp app = null;
            String tmpFile = null;
            String extension = "vsd";
            try
            {
                try
                {
                    app = (Microsoft.Office.Interop.Visio.InvisibleApp)Marshal.GetActiveObject("Visio.Application");
                }
                catch (System.Exception)
                {
                    app = new Microsoft.Office.Interop.Visio.InvisibleApp();
                    running = false;
                }
                Regex extReg = new Regex("\\.(\\w+)$");
                Match match = extReg.Match(inputFile);
                if (match.Success)
                {
                    extension = match.Groups[1].Value;
                }

                // We can only convert svg, vsdx and vsdm files with Visio 2013
                if (System.Convert.ToDouble(app.Version.ToString()) < 15 &&
                    ((String.Compare(extension, "vsdx") == 0) ||
                    (String.Compare(extension, "vsdm") == 0) ||
                    (String.Compare(extension, "svg") == 0)))
                {
                    Console.WriteLine("File type not supported in Visio version {0}", app.Version);
                    return (int)ExitCode.UnsupportedFileFormat;
                }

                bool pdfa = (Boolean)options["pdfa"] ? true : false;
                short flags = 0;
                if ((Boolean)options["readonly"])
                {
                    flags += 2;
                }
                if (!(Boolean)options["hidden"])
                {
                    app.Visible = true;
                }
                VisDocExIntent quality = VisDocExIntent.visDocExIntentPrint;
                if ((Boolean)options["print"])
                {
                    quality = VisDocExIntent.visDocExIntentPrint;
                }
                if ((Boolean)options["screen"])
                {
                    quality = VisDocExIntent.visDocExIntentScreen;
                }
                Boolean includeProps = !(Boolean)options["excludeprops"];
                Boolean includeTags = !(Boolean)options["excludetags"];

                var documents = app.Documents;
                Console.WriteLine("Opening file");
                documents.OpenEx(inputFile, flags);

                // Try and avoid dialogs about versions and convert SVG files to
                // visio to get ready for printing
                if (String.Compare(extension, "svg") == 0)
                {
                    extension = "vsd";
                }
                tmpFile = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + "." + extension;
                
                var activeDoc = app.ActiveDocument;
                activeDoc.SaveAs(tmpFile);
                activeDoc.ExportAsFixedFormat(VisFixedFormatTypes.visFixedFormatPDF, outputFile, quality, VisPrintOutRange.visPrintAll, 1, -1, false, true, includeProps, includeTags, pdfa);
                activeDoc.Close();

                Converter.releaseCOMObject(documents);
                Converter.releaseCOMObject(activeDoc);
                return (int)ExitCode.Success;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return (int)ExitCode.UnknownError;
            }
            finally
            {
                if (tmpFile != null)
                {
                    System.IO.File.Delete(tmpFile);
                }
                if (app != null && !running)
                {
                    app.Quit();
                }
                Converter.releaseCOMObject(app);
            }
        }
Exemple #8
0
        static int Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.Error.WriteLine("Invalid number of arguments.");
                Usage();
                return(3);
            }

            FileInfo sourceFileInfo = new FileInfo(args[0]);

            if (!sourceFileInfo.Exists)
            {
                Console.Error.WriteLine("Source file \"{0}\"doesn't exist.", sourceFileInfo.FullName);
                Usage();
                return(3);
            }

            string[] validExtensions = new string[] { ".vst", ".vsd" };
            if (!validExtensions.Contains(sourceFileInfo.Extension, StringComparer.InvariantCultureIgnoreCase))
            {
                Console.Error.WriteLine(String.Format("Source file extension must be one of: {0}", String.Join(", ", validExtensions)));
                Usage();
                return(3);
            }

            string referencePageNames = args[1];

            FileInfo targetFileInfo = new FileInfo(args[2]);

            if (targetFileInfo.Exists && targetFileInfo.IsReadOnly)
            {
                Console.Error.WriteLine("Target file exists and is readonly.");
                Usage();
                return(3);
            }
            if (!targetFileInfo.Directory.Exists)
            {
                Console.Error.WriteLine("Target file directory doesn't exist.");
                Usage();
                return(3);
            }
            if (!validExtensions.Contains(targetFileInfo.Extension, StringComparer.InvariantCultureIgnoreCase))
            {
                Console.Error.WriteLine(String.Format("Target file extension must be one of: {0}", String.Join(", ", validExtensions)));
                Usage();
                return(3);
            }
            if (String.Compare(sourceFileInfo.FullName, targetFileInfo.FullName, StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                Console.Error.WriteLine("Source and targer file are identical.");
                Usage();
                return(3);
            }

            string targetFile = targetFileInfo.FullName;

            File.Copy(sourceFileInfo.FullName, targetFile, true);
            File.SetAttributes(targetFile, FileAttributes.Normal);
            //Visio.Application visioApp = new Visio.Application(); // Visible Application
            Visio.InvisibleApp visioApp            = new Visio.InvisibleApp();
            Visio.Document     visioTargetDocument = visioApp.Documents.OpenEx(targetFile, (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visAddMacrosDisabled);

            Array pageNameArray;

            visioTargetDocument.Pages.GetNames(out pageNameArray);
            IList <string> pageNames = pageNameArray.Cast <string>().ToList();

            foreach (string referencePageName in referencePageNames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                bool referencePageContained = pageNames.Remove(referencePageName);
                if (!referencePageContained)
                {
                    visioApp.Quit();
                    File.Delete(targetFile);
                    Console.Error.WriteLine(String.Format("ReferencePageName \"{0}\" not found in \"{1}\".", referencePageName, sourceFileInfo.FullName));
                    Usage();
                    return(3);
                }
            }

            foreach (string pageName in pageNames)
            {
                Visio.Page page = visioTargetDocument.Pages[pageName];
                page.Delete(1);
            }

            visioTargetDocument.Save();

            if (referencePageNames != "Template")
            {
                foreach (Visio.Page page in visioTargetDocument.Pages)
                {
                    foreach (Visio.Shape shape in page.Shapes)
                    {
                        if (shape.get_CellExists("User.StateChartType", (short)0) != 0)
                        {
                            string stateChartType = shape.Cells["User.StateChartType"].FormulaU;
                            if (stateChartType == "GUARD(0)")
                            {
                                Console.WriteLine("Name={0} NameID={1} NameU={2}", shape.Name, shape.NameID, shape.NameU);

                                shape.get_Cells("Prop.TargetFile").FormulaU = "";

                                Console.WriteLine("Prop.TargetFile Formula={0} Value={1}", shape.get_Cells("Prop.TargetFile").FormulaU, shape.get_Cells("Prop.TargetFile").get_ResultStrU((short)Visio.VisToParts.visNone));
                            }
                        }
                    }
                }
            }

            visioTargetDocument.Save();

            visioTargetDocument.Close();

            visioApp.Quit();

            Console.WriteLine(String.Format("File written to \"{0}\"", targetFileInfo.FullName));

            return(0);
        }
Exemple #9
0
        private void generateVisio(Connection treeNode)
        {
            visapp = new IVisio.InvisibleApp();
            visapp.AlertResponse = 7; //autoAnswer NO on any alert
            visapp.Visible       = false;
            bool errorCatch = false;

            try
            {
                string _fileName = fileName.Text.Split('\\').Last();
                string _filePath = fileName.Text.Replace(_fileName, "");

                string templateFileName = Directory.GetCurrentDirectory() + "\\template.vss";
                string shapesFileName   = Directory.GetCurrentDirectory() + "\\shapes.vss";
                string newFullfileName  = _filePath + "\\result\\" + _fileName.Replace(".kml", ".vsd");

                if (!File.Exists(templateFileName))
                {
                    throw new Exception("Не найден шаблон выходного файла: " + templateFileName);
                }

                Directory.CreateDirectory(_filePath + "\\result\\");

                string caption  = "Поопорная схема ВЛ 0,4 кВ от ";
                string firstTmp = "";
                int    tpPos    = _fileName.IndexOf("ТП");
                if (tpPos >= 0)
                {
                    firstTmp = _fileName.Substring(tpPos, _fileName.Length - tpPos).Replace('_', '/').Replace(".kml", "");
                    string secondTmp = _fileName.Substring(0, tpPos - 1);
                    _fileName = firstTmp + " кВА " + secondTmp;
                }
                else
                {
                    throw new Exception("Не корректное название файла: " + fileName);
                }
                caption = caption + _fileName + " " + city.Text;

                IVisio.Document doc       = visapp.Documents.Open(templateFileName); // (short)IVisio.VisOpenSaveArgs.visAddHidden + (short)IVisio.VisOpenSaveArgs.visOpenNoWorkspace);
                IVisio.Document shapesDoc = visapp.Documents.Open(shapesFileName);   // (short)IVisio.VisOpenSaveArgs.visAddHidden + (short)IVisio.VisOpenSaveArgs.visOpenNoWorkspace);
                IVisio.Page     page      = doc.Pages[1];

                IVisio.Shape visioRectMaster = page.Shapes.get_ItemU("Sheet.1");
                visioRectMaster.Text = caption;

                visioRectMaster      = page.Shapes.get_ItemU("Sheet.509");
                visioRectMaster.Text = caption;

                visioRectMaster      = page.Shapes.get_ItemU("Sheet.496");
                visioRectMaster.Text = make.Text;

                visioRectMaster      = page.Shapes.get_ItemU("Sheet.508");
                visioRectMaster.Text = makeDate.Text;

                visioRectMaster      = page.Shapes.get_ItemU("Sheet.495");
                visioRectMaster.Text = chekedM.Text;

                visioRectMaster      = page.Shapes.get_ItemU("Sheet.507");
                visioRectMaster.Text = chekedDate.Text;

                int    pos2 = firstTmp.LastIndexOf('-');
                int    pos3 = firstTmp.LastIndexOf('/');
                string tmp2 = "?";
                if (pos2 != -1 & pos3 != -1 & pos3 > pos2)
                {
                    tmp2 = firstTmp.Substring(pos2 + 1, pos3 - pos2 - 1);
                }

                //visioRectMaster = page.Shapes.get_ItemU("Sheet.314");
                //visioRectMaster.Text = "РЛНД - " + tmp2;

                double newX = 5.9;
                double newY = 6.85;

                GenerateShapes(shapesDoc.Masters, ref page, mainNode, 0, newX, newY, firstTmp);

                doc.SaveAs(newFullfileName);
                doc.Close();
            }
            catch (Exception ex)
            {
                LogTextEvent(System.Drawing.Color.Red, ex.Message);
                errorCatch = true;
            }

            foreach (IVisio.Document aDoc in visapp.Documents)
            {
                aDoc.Close();
            }
            visapp.Quit();
            if (errorCatch)
            {
                throw new Exception("Ошибка формирвания выходного файла");
            }
        }
Exemple #10
0
        public static void GenerateGraph(DrawItem drawItem, ref Palette palette, ref string message, string savePath = null)
        {
            try
            {
                if (savePath == null)
                    return;

                var vapp = new Visio.InvisibleApp();

                var vdoc = vapp.Documents.Add("");

  
                try
                {

                    var snopes = new List<Snope>();



                    SetPageLayoutAndRouting(vapp.ActivePage);

                    vapp.ActiveDocument.SaveAs(savePath);
                    vdoc.Saved = true;


                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                vapp.Quit();
                Utilities.NullAndRelease(vdoc);
                Utilities.NullAndRelease(vapp);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }