5868 Window Maximized

V

Vignesh

Hi,
I have an application developed using VB 5 and has got the WORD automation incorporated. (Meaning from VB application, user can launch word templates designed for their needs). So long we were using Windows 98 as OS. Now i am moving to Windows XP & Office XP.

Now i have done the changes necessary my word automation. But whenever i run the program i get a message 'Window is maximized' ( I have already set the WORD OBJECT LIBRARY to XP Version, yet getting the same error). When i debug i find the error code no is 5868. And in particular, this error is shown when running the below mentioned command @ line no.4.
May i know what is the cause and how to resolve it ????


Line 1 Set loWord = New Word.Application
Line 2 With loWord
Line 3 .Application.Top = 0
Line 4 .Application.Resize Width:=Screen.Width / (Screen.TwipsPerPixelX * 2.65), Height:=Screen.Height /
Screen.TwipsPerPixelY
Line 5
..
..
Line 20 End With

Thanks
 
H

Harold

I tested your code and if Word is opened Maximized then I get the same error
you reported.
After instantiating the Word application set the Windowstate to normal.
Use this line loWord.WindowState = wdWindowStateNormal
--
Harold Kless, MCSD
Support Professional
Microsoft Technical Support for Business Applications
(e-mail address removed)

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Vignesh said:
Hi,
I have an application developed using VB 5 and has got the WORD automation
incorporated. (Meaning from VB application, user can launch word templates
designed for their needs). So long we were using Windows 98 as OS. Now i am
moving to Windows XP & Office XP.
Now i have done the changes necessary my word automation. But whenever i
run the program i get a message 'Window is maximized' ( I have already set
the WORD OBJECT LIBRARY to XP Version, yet getting the same error). When i
debug i find the error code no is 5868. And in particular, this error is
shown when running the below mentioned command @ line no.4.
May i know what is the cause and how to resolve it ????


Line 1 Set loWord = New Word.Application
Line 2 With loWord
Line 3 .Application.Top = 0
Line 4 .Application.Resize Width:=Screen.Width /
(Screen.TwipsPerPixelX * 2.65), Height:=Screen.Height /
 
P

Peter Hewett

Hi =?Utf-8?B?VmlnbmVzaA==?=

You can only set Word application .top property if the WindowState is
wdWindowStateNormal or wdWindowStateMinimize. Also, you can only use the
..Resize method if the WindowState is wdWindowStateNormal. Use someting like
this:

With Application
If .WindowState = wdWindowStateNormal Then
.Top = 0
.Resize Screen.Width / (Screen.TwipsPerPixelX * 2.65), _
Screen.Height / Screen.TwipsPerPixelY
End If
End With

HTH + Cheers - Peter
 
V

Vignesh

Hi Harold & Peter
Thanks for your valuable inputs. I assume that both of you are suggesting me to use "loword.applicaiton.windowstate=wdWindowStateNormal" as an alternative to" loword.application.resize........" property. Yes now i get no more errors. But the problem now is that once the template is generated, the focus doesnt go to word template rather it still stays on my application. But that should not be the way i want. Once the template is generated, the focus must be to Word template not the application

For your advice pse

Thanks once agai
 
P

Peter Hewett

Hi

Somewhere you obviously create or open a document. Just activate the document
object:

Dim docNew as Word.Document

Set docNew = Documents.Add "Template to use for new document"
donNew.Activate

HTH + Cheers - Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top