
void ImageToIncludePicture() {
InlineShape oShp;
if ((ActiveDocument.InlineShapes.Count != 0)) {
Scripting.FileSystemObject oFSO = new Scripting.FileSystemObject();
if ((oFSO.FolderExists("c:\\temp\\epub") == false)) {
if ((oFSO.FolderExists("c:\\temp") == false)) {
oFSO.CreateFolder("c:\\temp");
}
oFSO.CreateFolder("c:\\temp\\epub");
}
string strImgPath;
strImgPath = (ActiveDocument.Path + "\\images\\");
if ((oFSO.FolderExists(strImgPath) == false)) {
oFSO.CreateFolder(strImgPath);
}
Template oTmp;
string sPath;
string sToolPath;
sToolPath = "D:\\00_Projects\\ePub\\Templates\\text2img.exe";
img = 1;
foreach (oShp in ActiveDocument.InlineShapes) {
oShp.Select;
if ((Selection.Fields.Count == 0)) {
if ((Selection.Paragraphs(1).Range.Text != "")) {
Selection.Paragraphs.Style = "Normal";
}
string strImg;
string strExt;
strImg = oShp.Range.XML;
VBScript_RegExp_55.RegExp oReg = new VBScript_RegExp_55.RegExp();
Match oMat;
MatchCollection oMatC;
strImg = strImg.Replace('\r', "<br/>");
strImg = strImg.Replace('\n', "<br/>");
oReg.Pattern = "<w:binData w:name=\"wordml://(.*?)\">(.*?)</w:binData>";
oReg.Global = true;
oReg.IgnoreCase = true;
oReg.Multiline = true;
if ((oReg.test(strImg) == true)) {
oMatC = oReg.Execute(strImg);
oMat = oMatC.Item[0];
string strTest;
strTest = oMat.SubMatches(1);
strTest = oMat.SubMatches(1).Replace("<br/><br/>", "\n");
Open;
"c:\\temp\\ePub\\input.txt";
for (object Output; ; Output++) {
// TODO: # ... Warning!!! not translated
1;
Print;
// TODO: # ... Warning!!! not translated
1;
strTest;
Close;
// TODO: # ... Warning!!! not translated
1;
strExt = oMat.SubMatches(0);
Selection.Delete;
strExt = strExt.Substring((strExt.Length - 4));
Shell;
(sToolPath + (" \"c:\\temp\\epub\\input.txt\" \""
+ (strImgPath + ("\\image"
+ (Format(img, "00")
+ (strExt + "\""))))));
vbHide;
while ((oFSO.FileExists((strImgPath + ("\\image"
+ (Format(img, "00") + strExt)))) == false)) {
Selection.Fields.Add;
Selection.Range;
wdFieldIncludePicture;
("\"images/image"
+ (Format(img, "00")
+ (strExt + "\"")));
img = (img + 1);
}
}
}
}
}
}
}