I want to position an image on the page the user is looking at, however I cannot find how to get the currentl开发者_JAVA百科y visible page/scroll in pixels.
Anybody know which object and property could give me that?
Are you trying to control Word from outside Word or is it an integrated control?
I think you want: Object oMissed = doc.Paragraphs[1].Range;
This code below is for an InlineShape, not Shape object. Shape object is for text-wrapping.
Code:
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);
      }
   }
}
Microsoft: HOWTO: How To Get 32-bit Scroll Position During Scroll Messages
Similarly, you may want to look at this SO question on How do I get the scroll position from Microsoft Execl -- which I just realized was asked by you..
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论