不过你可以使用stream来操作,可能能达到你的要求,具体我没有用过!

解决方案 »

  1.   

    <object id=FileDialog style="left: 0px; TOP: 0px" classid="clsid:f9043c85-f6f2-101a-a3c9-08002b2f49fb" codebase="http://activex.microsoft.com/controls/vb5/comdlg32.cab">
    </object>
    <input type=button value="打开Word文档" onclick='OpenFile()'>
    <input type=button value="HTML格式" onclick='window.confirm(App.innerHTML)'>
    <div align=left id=App style="border:1 solid #000000;background-color:#FFFFFF;height:400px;overflow:auto;width:100%;z-index:2" contentEditable></div>
    <script>
    function OpenFile()
    {
     try
     {
      FileDialog.CancelError=true;
      FileDialog.Filter="Word模板|*.doc|Word模板|*.dot";
      FileDialog.ShowOpen();
      var WordApp=new ActiveXObject("Word.Application");
      WordApp.Application.Visible=false;
      var Doc=WordApp.Documents.Open(FileDialog.filename);
      Doc.Activate();
      Doc.Parent.Options.InsertedTextColor=4;
      Doc.Parent.Options.InsertedTextMark=2;
      Doc.Parent.Options.DeletedTextColor=4;
      Doc.Parent.Options.DeletedTextMark=1;
      Doc.TrackRevisions=true;
      Doc.PrintRevisions=true;
      Doc.ShowRevisions=true;
      Doc.Application.UserName="";
      var Range=Doc.Range();
      Range.Select();
      var Selection=WordApp.Selection;
      Selection.Copy();
      App.focus();
      document.execCommand("Paste");
      App.focus();
      WordApp.DisplayAlerts=false;
      Doc.Close();
      WordApp.DisplayAlerts=true;
      WordApp.Quit();
     }
     catch(e){}
     return false;
    }
    </script>
      

  2.   

    以上是模拟实现,如果需要处理Word文档需要自己写ActiveX组件.
    一般用RFC1867
    给你一段例子:实现将流提交到服务器活动脚本[ASP和JSP都可以,至于服务器处理可以参考
    http://blog.csdn.net/gjd111686/archive/2004/08/18/78324.aspx]
    这样就将本地Word传到服务器了,至于在本地处理Word,应该是比较容易了,用OLE处理很方便的,MSDN中有例子
    CInternetSession m_Session("DigitalTitan");
        CHttpConnection* pServer=NULL;
        CHttpFile* pFile=NULL;
        CString strServerName=m_ServerName;
        INTERNET_PORT nPort=(INTERNET_PORT)atoi(m_ServerPort);
    CString strURL=m_DesignFile;
        try
        {

            pServer=m_Session.GetHttpConnection(strServerName,nPort);
    //AfxMessageBox(strServerName,MB_ICONINFORMATION);
    pFile=pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,strURL,NULL,1,NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT);
    //AfxMessageBox(strURL,MB_ICONINFORMATION);

    CString strBoundary="-----------------------------7d33a816d302b6";//分界线视CGI程序做响应改动.
            pFile->AddRequestHeaders("Content-Type: multipart/form-data, boundary="+strBoundary);
            pFile->AddRequestHeaders("Accept: **");

    char* pBuf=new char[1024*10000];

    //构造表单开始
    FieldStruct* pFieldStruct=new FieldStruct;
    POSITION CurrentPosition;
    for(int iIndex=0;iIndex<m_FieldData.GetCount();iIndex++)
    {
    CurrentPosition=m_FieldData.FindIndex(iIndex);
    pFieldStruct=(FieldStruct*)m_FieldData.GetAt(CurrentPosition); strcat(pBuf,(LPTSTR)(LPCTSTR)strBoundary); strcat(pBuf,"Content-Disposition: form-data;name=\"");
    strcat(pBuf,(LPTSTR)(LPCTSTR)pFieldStruct->m_FieldName);
    strcat(pBuf,"\"\r\n\r\n");
    strcat(pBuf,(LPTSTR)(LPCTSTR)pFieldStruct->m_FieldValue);
    strcat(pBuf,"\r\n");

    strcat(pBuf,(LPTSTR)(LPCTSTR)strBoundary);
    }
    //构造表单结束
    //
    CStdioFile m_File;
    BYTE* pFileBuf=new BYTE[1024];
    CString strBuf;
    DWORD dwRead;
    strcat(pBuf,"Content-Disposition: form-data;name=\"FieldName\"\r\nfilename=\"FileName\"\r\n");
    //AfxMessageBox(pBuf,MB_ICONINFORMATION);
    if(m_File.Open(strTempDocPath,CFile::modeRead|CFile::typeBinary))
    {
    do
    {
    dwRead=m_File.Read(pFileBuf,1024);
    //文件处理.
    }
    while(dwRead>0);
    m_File.Close();
    }
    //
    DeleteFile(strTempDocPath);
    strcat(pBuf,(LPTSTR)(LPCTSTR)strBuf);
    strcat(pBuf,"\r\n");
    strcat(pBuf,(LPTSTR)(LPCTSTR)strBoundary);
    strcat(pBuf,"--");
    //CString strBufLen;
    //strBufLen.Format("长度:%d",strlen(pBuf));
    //AfxMessageBox(strBufLen,MB_ICONINFORMATION);
    if(pFile->SendRequest(NULL,0,(LPVOID)pBuf,strlen(pBuf))==0)
    {
    AfxMessageBox("网络异常...",MB_ICONINFORMATION);
    }
    else
    {
    //AfxMessageBox("完成设计...",MB_ICONINFORMATION);
    }
    pFile->Close();
    pServer->Close();
        }
        catch(CInternetException* e)
    {
    char strErrorBuf[255];
    e->GetErrorMessage(strErrorBuf,255,NULL);
    AfxMessageBox(strErrorBuf,MB_ICONINFORMATION);
    }
        delete pFile;
        delete pServer;
        m_Session.Close();
      

  3.   

    金刚老大又出动了:)
    不过楼主说的点一个按钮,word自动保存好像JavaScript实现不了