I am getting this error message in this context:
int left = 0;
int top = 0;
int width = 0;
int height = 0;
Word.Range rng2 = rng;
Microsoft.Office.Interop.Word.Window.GetPoint(out left, out top, out width, out height, rng);
How can I fix it?
Window is non static, you need to create a new instance of it in order to use it.
//using Word = Microsoft.Office.Interop.Word;
Word.Application application = this.Application;
//Not sure how you create your application object, just including this incase you're not using VSTO
//Word.Application application =
//(Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
//OR
//Word.Application application = new Word.Application();
Word.Range rng = application.ActiveDocument.Range();
int left,top,width,height = 0;
Word.Range rng2 = rng;
application.ActiveWindow.GetPoint(out left, out top, out width, out height, rng);
OR
Microsoft.Office.Interop.Word.Window window = application.ActiveWindow;
window.GetPoint(out left, out top, out width, out height, rng);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.