Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
2

Save as ai, svg and wmf script error

New Here ,
Mar 13, 2024 Mar 13, 2024

Can someone help me with fixing the error in script (in red text below)? I'm getting error as in the pic

Padmaprasad36061084lyqa_0-1710368750699.png


// Prompt user for file name
var fileName = prompt("Enter file name (without extension):", "Untitled");

// Check if user canceled the prompt
if (fileName === null) {
alert("Saving canceled.");
} else {

// Save as SVG
var svgOptions = new ExportOptionsSVG();
svgOptions.embedRasterImages = true;
svgOptions.cssProperties = SVGCSSPropertyLocation.STYLEELEMENTS;
svgOptions.fontSubsetting = SVGFontSubsetting.None;
svgOptions.preserveEditability = true;

var svgFile = new File("C:\\temp\\" + fileName + ".svg");
app.activeDocument.exportFile(svgFile, ExportType.SVG, svgOptions);

// Save as WMF
var wmfOptions = new ExportOptionsWMF();
wmfOptions.resolution = 300;

var wmfFile = new File(fileName + ".wmf");
app.activeDocument.exportFile(wmfFile, ExportType.WMF, wmfOptions);

// Save as AI
var aiOptions = new IllustratorSaveOptions();
var aiFile = new File("C:\\temp\\" + fileName + ".ai");
app.activeDocument.saveAs(aiFile, aiOptions);

// Alert user that files are saved
alert("Files saved as C:\\temp\\" + fileName + ".svg and C:\\temp\\" + fileName + ".ai");
}

TOPICS
Scripting
173
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Mar 13, 2024 Mar 13, 2024

Hi @Padmaprasad36061084lyqa, as far as I can tell there is no scripting support for WMF format. (At least in AI 28.3)

- Mark

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 14, 2024 Mar 14, 2024
LATEST

you could record an Action to epxort to WMF and have your script play the action

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines