Search code examples
javascriptms-wordactivexshellexecute

Launching winword with a file using ActiveX


How can I launch Word with a document path from activeX like for example:

function RunWord(cmdline, args){
var v;
v = new ActiveXObject("Shell.Application");
v.ShellExecute(cmdline+" "+args);
}

where cmdline is 'Word' that is a shortcut link in one of the system folder and args is the path to file like 'C:\Projects\Schedule.doc'

The problem is it combine the string like 'Word C:\Projects\Schedule.doc' and then give an error saying it does not find this application, however when I launch word alone without args it works ok.

Any ideas ?


Solution

  • Do you need to escaped the backslashes in your filename? I.e. use

    'C:\\Projects\\Schedule.doc'
    

    instead of

    'C:\Projects\Schedule.doc'