VC中对word每页文件的单独拷贝

wDoc.Select();
    WordSelection Sel=word->GetSelection();
    long lCurrentStart=Sel.GetStart();
    long lCurrentEnd=lCurrentStart;
    long lDocumentEnd=Sel.GetEnd();
    Sel.Collapse(COleVariant((short)1));//折叠范围或选定内容                                                //1.wdCollapseStart将选定内容折叠到选定内容的开头                                                  //0.wdCollapseEnd将选定内容折叠到选定内容的结尾。


    WordBrowser browser;
    WordRange range;
    int mIndex=0;
    while(lCurrentEnd<lDocumentEnd)
    {
     browser=word->GetBrowser();
     browser.SetTarget(1);//wdBrowsePage按页浏览
     browser.Next();

     lCurrentEnd=Sel.GetEnd();
     if(lCurrentStart==lCurrentEnd)
      lCurrentEnd=lDocumentEnd;

     range=wDoc.Range(COleVariant(lCurrentStart),COleVariant(lCurrentEnd));

     locksingle2.Lock();   //-----加锁
     range.CopyAsPicture();

     ::OpenClipboard(NULL); //打开剪贴板
     HANDLE hClip=::GetClipboardData(CF_ENHMETAFILE);//图元文件
     HENHMETAFILE hEnhMetaFile=(HENHMETAFILE)hClip;
     CString strN="";
     strN.Format("-w%d",mIndex++);
     HENHMETAFILE hMetaFile=CopyEnhMetaFile(hEnhMetaFile,(LPCTSTR)(strN+".emf"));
     DeleteEnhMetaFile(hMetaFile);
     EmptyClipboard();//清空剪贴板
     CloseClipboard();//关闭剪贴板

     locksingle2.Unlock();//----解锁

     range.ReleaseDispatch();
     browser.ReleaseDispatch();

     lCurrentStart=Sel.GetEnd();//下一页

    }

你可能感兴趣的:(null,browser)