生活如麻 发表于 2015-9-30 07:56:03

终于获取了SharePoint.OpenDocument对象打开的Word对象

  网上很多地方介绍了如何用SharePoint.OpenDocument打开基于WebDAV协议的Word文档,可是打开后,如果对文档进行一些设置操作,却苦于没有Word对象。
  我这里实现了得到Word.Application对象,可以进行设置文档域一类的操作了。
  可是,我本来想得到文档的保存事件并激活我的处理函数,目前这里卡住了,貌似没有出路。谁有?
  

Code
      function initWordApp(word)
      {
            //word.Application.ActiveDocument;
            alert(word);
      }
      
      function getSPOpenDocumentObject()
      {
            if(window.sharePoingOpentDocuments)
                return window.sharePoingOpentDocuments;
            else
            {
                var progids = ["SharePoint.OpenDocuments.3","SharePoint.OpenDocuments.2","SharePoint.OpenDocuments.1"];
                for(var i = 0; i < progids.length; ++i)
                {
                  try
                  {
                        return (window.sharePoingOpentDocuments = new ActiveXObject(progids));
                  }
                  catch(e)
                  {}
                }
               
                return null;
            }
      }
      
      function OpenWord(strDocFilePathName)
      {
            var openDocObj;
            openDocObj = getSPOpenDocumentObject();
            var ret = openDocObj.editDocument(strDocFilePathName,"Word.Document");
            
            window.setTimeout(function(){
                var word = null;
                try
                {
                  word = GetObject(strDocFilePathName);
                }
                catch(e)
                {
                  window.setTimeout(arguments.callee,200);
                }
                if(word)
                {
                  initWordApp(word);
                }
            },200);
            
      }
页: [1]
查看完整版本: 终于获取了SharePoint.OpenDocument对象打开的Word对象