This article has been submitted by Ranjith. He is a Siebel certified consultant working on Siebel EAI.

Requirement:

Saving an exported file to the client machine running Internet explorer, allowing the user to choose the location. This called for a FileSaveAs dialog box popping up. After a lot of searching on the net, I found it could be done in Javascript with the help of following code:

Solution:


var File = "this is the data"
var objDialog =new ActiveXObject("SAFRCFileDlg.FileSave")
objDialog.FileName = “Filename”;
objDialog.FileType = "File File";
var intReturn = objDialog.OpenFileSaveDlg();
if(intReturn)
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f1 = fso.CreateTextFile(objDialog.FileName, true,true);
// Write a File Hierarchy
f1.Write(File);
// Close the file.
f1.Close();
}

You can add this code in the browser script and see it in action.

Please Note (by Neel) : I personally tried this code and it seems that it only works on Windows XP OS. It seems Microsoft has deprecated SAFRCFileDlg.FileSave object and the library is not available in other operating systems except Windows XP.

Hope this helps.

OkAvarageGoodVery GoodExcellent (2 votes, average: 4 out of 5)
Loading ... Loading ...

Related Posts