Open App to spesific size (1 Viewer)

Freshman

Registered User.
Local time
Today, 13:45
Joined
May 21, 2010
Messages
437
Hi all,

I'm using the Shell command in VBA to open a 3rd party app.
But I want to open in to a spesific location and size on the screen.

A Google seach gave me this solution:

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

class Program {
static void Main(string[] args) {
var prc = Process.Start("notepad.exe");
prc.WaitForInputIdle();
bool ok = MoveWindow(prc.MainWindowHandle, 0, 0, 300, 200, false);
if (!ok) throw new System.ComponentModel.Win32Exception();
}
[DllImport("user32.dll", SetLastError = true)]
private static extern bool MoveWindow(IntPtr hWnd, int x, int y, int width, int height, bool repaint);
}

But firstly I don't know what lanuage it is.
Secondly I need to do it in VBA.

Can anyone help please?

Thanks
 

DJkarl

Registered User.
Local time
Today, 06:45
Joined
Mar 16, 2007
Messages
1,028
Hi all,

I'm using the Shell command in VBA to open a 3rd party app.
But I want to open in to a spesific location and size on the screen.

A Google seach gave me this solution:



But firstly I don't know what lanuage it is.
Secondly I need to do it in VBA.

Can anyone help please?

Thanks

that code is C#, here is the MoveWindow API in VBA. To get the handle to the program you will need to use the FindWindow API to locate the window and get the handle to the program since the Shell command doesn't return a process or window handle.

Code:
Private Declare Function MoveWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
 

Freshman

Registered User.
Local time
Today, 13:45
Joined
May 21, 2010
Messages
437
Thanks - will play arond with that
 

Users who are viewing this thread

Top Bottom