Hi All,
I have some requirments that to open MS-Word, MS- Excel , MS-PowerPoint and MS- Outllook applications from SharePoint enviornment.
This is possible by using "Process" Class in System.Diagonostics as
Process wordApp = new Process();
wordApp.StartInfo.FileName= "WinWord.exe";
wordApp.Start();
wordApp.StartInfo.FileName= "WinWord.exe";
wordApp.Start();
But the problem in SharePoint is the Process is started but with the Credentials of "Network Services" so the word application is not visible.
The above solution is working in any normal ASP.Net web application but not in SharePoint. So we try a work around as use javascript and create ActiveX objects and Pass the Application Name as arguments.
TheCode is as ...
For MS-Word Application.
var WordApplication=new ActiveXObject("Word.Application");
WordApplication.Visible=true; // "Visible" is in the Word Object Model
WordApplication.Documents.Add();
For MS-Excel Application.
var ExcelApplication=new ActiveXObject("Excel.Application");
ExcelApplication.Visible=true; // "Visible" is in the Excel Object Model
ExcelApplication.Workbooks.Add();
For MS-PowerPoint Application.
var PPTApplication=new ActiveXObject("Powerpoint.Application");
PPTApplication.Visible=true; // "Visible" is in the PowerPoint Object Model
PPTApplication.Presentations.Add();
PPTApplication.Visible=true; // "Visible" is in the PowerPoint Object Model
PPTApplication.Presentations.Add();
For MS-OutLook Application.
var objO = new ActiveXObject('Outlook.Application');
var objNS = objO.GetNameSpace('MAPI');
var olInbox = objNS.GetDefaultFolder(6);
olInbox.Display();
var objNS = objO.GetNameSpace('MAPI');
var olInbox = objNS.GetDefaultFolder(6);
olInbox.Display();
Try this code in Script.
Prerequsite :
There some prerequsites for this application,
- The application is installed at client machine, because it will open client local application but not on servers application.
- There is settings for running this scripts as,
Tools > Internet Options… > choose tab Security > click button Custom level > scroll > to 'Run ActiveX controls and plug-ins' > select ‘prompt’ or ‘enable’.