Skip to main content
Participant
March 13, 2024
Question

Save as ai, svg and wmf script error

  • March 13, 2024
  • 2 replies
  • 217 views

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


// 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");
}

This topic has been closed for replies.

2 replies

CarlosCanto
Community Expert
Community Expert
March 14, 2024

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

m1b
Community Expert
Community Expert
March 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