Launch ms word template as new document from IE
I have a requirement to launch .dot files (ms word templates) as new documents from the browser...
Let me explain... if you click on a .dot file in Windows Explorer it opens a new document and runs any macros... you can right click and edit the template...
I want to link to the files, so I use <a href="file://myserver/templates/letter.dot">Letter</a>
... However this then prompts for the "Download File" dialogue box... and then if I click "Open" it opens the template in edit mode... not the requ开发者_StackOverflow中文版ired new document mode...
This may be a technical impossibility but can I achieve the desired result in ActiveX or something??
You need to set the right headers from the server (I don't think you can do this with local files)
Header:
//Word
header('Content-Type: application/vnd.ms-word');
//Excel
header('Content-Type: application/vnd.ms-excel');
//To "force" as a download attachment vs. opening in the browser
header('Content-Disposition: attachment; filename="template.dot"');
Instead of linking to the .dot files directly, link to .lnk (Windows link files)... this magically makes the template open in the correct way.
From NotePad, make a .bat file with one simple instruction:
start C:\\MyTemplate.dotx
(where you replace C:\MyTemplate.dotx by the actual path and name of your template) Then make a link to that bat-file instead of to your template.
精彩评论