我想把word文档的内容以图片形式复制到剪切板,然后再保存成位图格式。可是剪切板上总是找不到对象。但是在“画图”中可以粘贴上内容。这是怎么会事啊?应当怎么改进?
object OFileName = (object)filename;
object OMissing = System.Reflection.Missing.Value;
///////////////////////打开word////////////////////////////
Word.ApplicationClass wordApp = new Word.ApplicationClass();
Document wordDoc = wordApp.Documents.Open(ref OFileName,ref OMissing,ref OMissing,ref OMissing,ref OMissing,ref OMissing,ref OMissing,ref OMissing,ref OMissing,ref OMissing,ref OMissing,ref OMissing);
wordApp.Selection.WholeStory(); //全选
wordApp.Selection.CopyAsPicture(); //以图片形式复制
wordDoc.Close(ref OMissing ,ref OMissing,ref OMissing);
wordApp.Quit(ref OMissing,ref OMissing,ref OMissing);
Bitmap bt = null;
IDataObject ido = Clipboard.GetDataObject(); //问题出在这里,ido总是NULL,为什么?
if(ido != null)
{
if(ido.GetDataPresent(DataFormats.Bitmap))
{
bt = (Bitmap)ido.GetData(DataFormats.Bitmap);
}
}return bt;

解决方案 »

  1.   

    怎么没人啊,好歹说一下,这个方法可不可行啊。
      

  2.   

    试过了,在你说出错的地方我得到东西了,但无法将其转换为图片为什么要这样做呢?要达到什么样的目的呢?
      

  3.   

    我想做一个公文审批程序,把文档所有内容(包括表格),转换成图片,然后,以图片的形式在流程中传阅审批盖章。可是现在没法转换成图片。