2009-12-02 69 views

回答

0

您是否试图从外部Word控制Word或者它是一个集成控件?

我想你想:Object oMissed = doc.Paragraphs[1].Range;

下面这段代码是一个InlineShape,而不是形状对象。 Shape对象用于文本包装。

代码:

using System;  
using System.Collections.Generic;  
using System.ComponentModel;  
using System.Data;  
using System.Drawing;  
using System.Linq;  
using System.Text;  
using System.Windows.Forms;  
using Word = Microsoft.Office.Interop.Word; 


namespace WordAddIn3 
{ 

    public partial class Form1 : Form 
    { 

     public Form1() 
     { 

      InitializeComponent(); 

     } 

     private void button1_Click(object sender, EventArgs e) 
     { 

      Word.Application wdApp = Globals.ThisAddIn.Application; 
      Word.Document doc = wdApp.ActiveDocument; 

      string fileName = "c:\\testimage.jpg"; //the picture file to be inserted 

      Object oMissed = doc.Paragraphs[1].Range; //the position you want to insert 
      Object oLinkToFile = false; //default 
      Object oSaveWithDocument = true;//default 

     doc.InlineShapes.AddPicture(fileName, ref oLinkToFile, ref oSaveWithDocument, ref oMissed); 
     } 

    } 



} 

微软:HOWTO: How To Get 32-bit Scroll Position During Scroll Messages

同样,你可能想看看这太问题上How do I get the scroll position from Microsoft Execl - 我才意识到有人问你..

+0

在期间滚动不会帮助我,我很害怕。在我的应用程序进入游戏之前,用户可能已经滚动了。我希望Execl的答案会导致Word的答案,但API看起来不够完美。 – 2009-12-02 14:08:48

+0

Gotcha。看到我编辑的消息。 – 2009-12-02 14:13:40

相关问题