position application at launch

  • Thread starter Gary''s Student
  • Start date
G

Gary''s Student

When starting an application like Word, how can I automatically select the
position and size of the window on the screen?
 
K

Karl E. Peterson

Gary''s Student said:
When starting an application like Word, how can I automatically
select the position and size of the window on the screen?

From within, or externally?
 
G

Gary''s Student

From without. I am launching Word and Outlook from a script rather than
double-clicking an icon. I have noticed that Windows "remembers" the last
position of an application after it is closed. If I double-click and icon,
the application usually launches in the same screen area. There is probably
an area in the registry that contains this data. I am hoping there are some
APIs available to control it.
 
K

Karl E. Peterson

Gary''s Student said:
From without. I am launching Word and Outlook from a script rather
than double-clicking an icon. I have noticed that Windows
"remembers" the last position of an application after it is closed.
If I double-click and icon, the application usually launches in the
same screen area. There is probably an area in the registry that
contains this data. I am hoping there are some APIs available to
control it.

Looks like it's stored within the binary structure found here (substituting
the appropriate version number, of course):

HKCU\Software\Microsoft\Office\9.0\Word\Data

I'm not sure that structure documented anywhere, and would probably be
really messy to modify prior to launching Word. What sort of script are you
using? If one that can access the API, there are ways to watch for the new
instance, and move it as you wish. Otherwise, there _may_ be a WMI method,
but you'd want to ask that in one of the scripting groups for the best
chance of a solution.
 
G

Gary''s Student

Thank you for your help.

In the UNIX world, I would just set the xview parameters and proceed
 
K

Karl E. Peterson

Gary''s Student said:
Thank you for your help.

Have I helped?
In the UNIX world, I would just set the xview parameters and proceed

So programs there don't store user preferences, and act on them? That's all
that Word is doing, here. That's where it gets tricky, really. If this
were purely a startup parameter, as it _can_ be if you use CreateProcess to
fire it up, it'd be a cinch. But Word is taking matters into its own hands
after the process has been fired up. I'm betting that it will ignore the
settings specified by CreateProcess. (Although, you can test that by
creating a shortcut to the app, and setting the initial windowstate
parameter.)

The real problem is, Word just isn't a normal app in any sort of way.
Firing up a "new instance" will really cause a new window to be opened in an
existing instance, if one is already running. So, you end up battling
"Microsoft logic", and basically banging your head on the wall. If, OTOH,
you were firing up a specific document, you could have code within it to
control the position of it's parent window.

Sorry... Karl
 
T

Tushar Mehta

From without. I am launching Word and Outlook from a script rather than
double-clicking an icon. I have noticed that Windows "remembers" the last
position of an application after it is closed. If I double-click and icon,
the application usually launches in the same screen area. There is probably
an area in the registry that contains this data. I am hoping there are some
APIs available to control it.
Depending on what you mean by script, this might be much simpler than
worrying about APIs or registry entries. If the script you refer to is
VBScript (or JScript), use something along the lines of

Option Explicit

Sub testWordPosition()
Dim x As Object
Const wdWindowStateNormal = 0
On Error Resume Next
Set x = GetObject(, "word.application")
On Error GoTo 0
If x Is Nothing Then Set x = CreateObject("word.application")
x.Visible = True
x.WindowState = wdWindowStateNormal
x.Left = 30
x.Top = 10
End Sub

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
K

Karl E. Peterson

Tushar said:
Depending on what you mean by script, this might be much simpler than
worrying about APIs or registry entries. If the script you refer to
is VBScript (or JScript), use something along the lines of

Option Explicit

Sub testWordPosition()
Dim x As Object
Const wdWindowStateNormal = 0
On Error Resume Next
Set x = GetObject(, "word.application")
On Error GoTo 0
If x Is Nothing Then Set x = CreateObject("word.application")
x.Visible = True
x.WindowState = wdWindowStateNormal
x.Left = 30
x.Top = 10
End Sub

Yeah, I was thinking along similar lines ("from within"), but didn't ask as
clearly. Thanks for re-raising that possibility.
 
T

Tushar Mehta

{snip}

{snip}


Yeah, I was thinking along similar lines ("from within"), but didn't ask as
clearly. Thanks for re-raising that possibility.
Hi Karl,

Let's see what GarysStudent (the OP) has to say about it.
--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
G

Gary''s Student

A slight mod to your suggestion work just fine. It is not apparent to my
users if the screen setup occurs before or after launch, so the VB approach
is perfectly acceptable.

Thank you all for your help.
 

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