I want to position an image on the page the user is looking at, however I cannot find how to get the currently visible page/scroll in pixels.
Anybody know which object and property could give me that?
I want to position an image on the page the user is looking at, however I cannot find how to get the currently 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..