Link to home
Start Free TrialLog in
Avatar of BBC
BBC

asked on

VBA/OLE: Maximize Word97 from within Access97

I use the following VBA-code to try to display and maximize Word 97 from within Access 97. Word shows up but isn't maximized. Why ?
My customer also complains that Word starts but does not pop up in front. So they need to click it to front. Has anyone solved these problems ?

Set wrd = CreateObject("Word.Application.8")
<...>
wrd.Visible = True
If wrd.Application.WindowState <> wdWindowStateMaximize Then wrd.Application.WindowState = wdWindowStateMaximize
Avatar of ture
ture

BBC,

My first guess is that the constant wdWindowStateMaximize isn't assigned properly. It's value should be 1. Try using the value 1 instead of the constant.
Also... you don't need to use wrd.Application.WindowState. wrd IS already an application object so wrd.WindowState is good enough.

Try this code. It worked well for me.

  Dim wrd As Word.Application
  Set wrd = CreateObject("Word.Application.8")
  wrd.Visible = True
  If wrd.WindowState <> 1 Then wrd.WindowState = 1

Ture Magnusson
Karlstad, Sweden
Avatar of BBC

ASKER

Uhh... I hate magic constants. But this thing is MESSED UP (MS Office).
Your suggestion works, so I'll use it. Thanks.
Did you ever try:

 if wrd.WindowState <> 1 Then wrd.WindowState = 1
wrd.Visible = True

You get a different result. You get Word without Word ... ;-)

PS: Submit it as answer and you'll get the points.
ASKER CERTIFIED SOLUTION
Avatar of ture
ture

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial