InvokeMember opens a Word document and saves it as an Html page. How to close the Html first and then exit Word? _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:17:25
Original
1416 people have browsed it

public partial class CountyTown : System.Web.UI.Page
{
public string countyName = string.Empty; //Township name
public string documentFullName = string.Empty; //Full plan weigh ( Including suffix name)
public string documentName = string.Empty; //Plan name

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
//Get the file name based on the passed township name
countyName = Request["space"];
documentFullName = "Jiangtan Township's prevention of typhoons and flash floods Prevention plan.docx";
documentName = documentFullName.Substring(0,documentFullName.LastIndexOf('.'));
>                                                                                                                                                                                                    
                                                                                                                                                       Type wordType = word.GetType();
Documents docs = word.Documents; // Open file
Type docsType = docs.GetType();
object fileName = Server.MapPath(@"~UpLoad") documentFullName;
Document doc = (Document )docsType.InvokeMember("Open",BindingFlags.InvokeMethod,null, docs,new Object[]{fileName, true, true }); // Convert format, save as


Type docType = doc .Gettype ();
Object savefilename = server.mappath (@"upload") documentname ".html"; ClientScript .RegisterClientScriptBlock(GetType(), "", "");

//Save HTML (Error: Word cannot save this file because it has been opened elsewhere. )
docType.InvokeMember("SaveAs",BindingFlags.InvokeMethod, null, doc, new object[] {
saveFileName, WdSaveFormat.wdFormatHTML });
// Exit Word
wordType.InvokeMember("Quit",BindingFlags.InvokeMethod, null, word, null);
   
   Response.Redirect("~/Upload/" documentName ".html"); 🎜>
Reply to the discussion (solution)


Do not open the word document for your local test, and close the open word document.

Don’t have a word document open?

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template