// System.Windows.Forms - Добавить в ссылки
using System;
using System.IO;
using System.Collections.Generic;
using System.Windows.Forms;
using TFlex.Model;
namespace NewMacroNamespace
{
public class NewMacroClass
{
public static void NewMacro()
{
List<Document> lst = new List<Document>();
System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog();
string pathFolder = "";
if (folderDialog.ShowDialog() == DialogResult.OK)
{
pathFolder = folderDialog.SelectedPath;
}
DirectoryInfo dirInfo = new DirectoryInfo(pathFolder);
FileInfo[] files = dirInfo.GetFiles();
foreach (FileInfo file in files)
{
Document document = TFlex.Application.OpenDocument(file.FullName);
ExportToPDF ex = new ExportToPDF(document);
string path = document.FileName.ToString();
int slash = 0;
int pnt = 0;
for (int i = 0; i < path.ToCharArray().Length; i++)
{
if (path[i] == '\\')
slash = i;
}
slash++;
string res = path.Substring(slash);
for (int i = 0; i < res.ToCharArray().Length; i++)
{
if (res[i] == '.')
pnt = i;
}
res = res.Substring(0, pnt);
ex.Export(pathFolder + "\\" + res + ".pdf");
}
}
}
}
using System;
using System.IO;
using System.Collections.Generic;
using System.Windows.Forms;
using TFlex.Model;
namespace NewMacroNamespace
{
public class NewMacroClass
{
public static void NewMacro()
{
List<Document> lst = new List<Document>();
System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog();
string pathFolder = "";
if (folderDialog.ShowDialog() == DialogResult.OK)
{
pathFolder = folderDialog.SelectedPath;
}
DirectoryInfo dirInfo = new DirectoryInfo(pathFolder);
FileInfo[] files = dirInfo.GetFiles();
foreach (FileInfo file in files)
{
Document document = TFlex.Application.OpenDocument(file.FullName);
ExportToPDF ex = new ExportToPDF(document);
string path = document.FileName.ToString();
int slash = 0;
int pnt = 0;
for (int i = 0; i < path.ToCharArray().Length; i++)
{
if (path[i] == '\\')
slash = i;
}
slash++;
string res = path.Substring(slash);
for (int i = 0; i < res.ToCharArray().Length; i++)
{
if (res[i] == '.')
pnt = i;
}
res = res.Substring(0, pnt);
ex.Export(pathFolder + "\\" + res + ".pdf");
//закрываем документ
document.Close();
document = null;
}
}
}
}
Научил закрывать документ .grb после экспорта. А вот как запретить макросу не открывать .pdf документ при создании. За это вроде отвечает свойство OpenExportFile, но как его применять ума не приложу, т.к. не программист. Может кто разбирающийся в C# подскажет?