我想在用户正在查看的页面上放置图像,但是我无法找到如何以像素为单位获取当前可见的页面/滚动。
有人知道哪个对象和财产可以给我这个吗?
答案 0 :(得分:0)
您是尝试从Word外部控制Word还是集成控件?
我想你想要:Object oMissed = doc.Paragraphs[1].Range;
以下代码适用于InlineShape,而非Shape对象。 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);
}
}
}
Microsoft:HOWTO: How To Get 32-bit Scroll Position During Scroll Messages
同样地,你可能想在 How do I get the scroll position from Microsoft Execl 上查看这个问题 - 我刚才意识到这是你的问题。