centering and sizing a word automation active window

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I am trying to figure out how I can center and size a word application
active window within my vb.net form when the word document is open using
automation so that the word window doesn't extend beyond/overlap the form
window (top, left, width or top).

Thanks

Steve
 
Just an add on note...Here's the code I have so far

WordApp.ActiveWindow.View.Zoom.Percentage = 75
WordApp.ActiveWindow.WindowState =
Word.WdWindowState.wdWindowStateNormal
WordApp.ActiveWindow.Height = Me.Height - 300
WordApp.ActiveWindow.Width = Me.Width - 275
WordApp.ActiveWindow.Top = Me.Top + ((Me.Height -
WordApp.ActiveWindow.Height) / 2)
WordApp.ActiveWindow.Left = Me.Left + ((Me.Width -
WordApp.ActiveWindow.Width) / 2)

Where me. is the form initiating the word automation. Me.top = 113.
Me.height = 767. Me.Left = 242. Me.width = 796. So based on my
calculations, ActiveWindow.height = 467. ActiveWindow.width = 521 making it
smaller than the form it displays on top of. ActiveWindow.Top would then
be equal to 263. And ActiveWindow.Left would then be equal to 380. Which
should center the activewindow in the middle of the form. But instead it
displays it to the right and below.

Not sure what I'm doing wrong.

Thanks

Steve
 
Back
Top