INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Resize an Application Window

Resize an Application Window

(OP)
I've tried a couple of methods for resizing an application window, but neither of these options work - they result in a compile error.

Method #1
---------
WshShell.moveTo 1030,110 ' Moves the window position
' horizontally, vertically and
WshShell.resizeTo 225,175 ' changes the width and height

Method #2
---------
With Application
.WindowState = wdWindowStateNormal
.Resize Width:=InchesToPoints(7), Height:=InchesToPoints(6)
End With

Could someone please offer a solution to this issue?

RE: Resize an Application Window

Hey, Sparky (love that name, reminiscent of Big John and Sparky from the 50s)

Don't have a solution, just an observation.

You don't resize an Application object. There is an Application Object Property for the Window that you need to find. First you must instantiate an application object using CreatObject or GetObject.

However, the Attachmate VB Editor is pretty bland when it comes to editing features. I almost always coded in Excel VBA since my criteria and results came from/went to Excel for further analysis and distribution. Excel VBA has a Watch Window when one can DISCOVER the properties so mentioned.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Resize an Application Window

(OP)
Thanks, Skip!

Hey, Skip is a pretty cool name as well! I remember the Skip & Bob show from the early 60s.... Had my picture taken with Bob at a breakfast celebration way back then!

I'll have to take a look - I do create the object using CreateObject:

Dim WshShell As Object
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "explorer"

Here's to digging a little deeper....

RE: Resize an Application Window

so is WshShell the application object of interest?

If so, then regarding method 2:

CODE

With WshShell
.WindowState = wdWindowStateNormal
.Windows(1).Resize Width:=InchesToPoints(7), Height:=InchesToPoints(6) 
wdWindowStateNormal Appears to be a Microsoft Word constant. You might need to find the numeric value of this constant to use.

I also added a property .Windows(1) meaning for the Application object the Windows collection qualified to the first in the collection. Just a guess that you might care to try.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Resize an Application Window

(OP)
Thanks, Skip! Unfortunately, even that continues to give me a compile error.

RE: Resize an Application Window

This brings up Windows File Explorer. Is that what you want?

CODE

Sub ResizeWindow()
    Dim WshShell As Object
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run "explorer"
End Sub 

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Resize an Application Window

Doing some snooping using the above code and WsShell has only 2 properties: CurrentDirectory (String) and SpecialFolders (Collection)

There is no WINDOWS property.

At this point, you might be better off in the VBScript forum, cuz your code has nothing to do with Attachmate at this juncture.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Resize an Application Window

(OP)
Okay, Skip - thanks!

RE: Resize an Application Window

(OP)
Thanks to Skip's advice I went to the VB Script forum and received some additional support from them. However, it appears that the Attachmate VB Editor contains an older version of VB, or at the very least a subset of what's available in the Excel VB Editor. I needed to use the Excel VB Editor to compile and run the following macro - in the Attachmate VB Editor it won't compile.

--------------------------------------------
'
' Establish Sleep subroutine from kernel32.dll file.
'
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub Auto_Open()
'
' Set up system variables.
'
Dim myShell As Object
Dim myExplorerWindow As Object
Dim iCnt As Integer
Dim WshShell As Object
'
' Establish location of comment files.
'
Dim FolderPath As String
FolderPath = "G:\Desktop Folder"
'
' Load Windows Explorer.
'
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "explorer"
Sleep 3000 ' Pause for 3 seconds.
' WshShell.AppActivate "Explorer"
'
' Set explorer to folder path.
'
WshShell.SendKeys ("%d")
WshShell.SendKeys (FolderPath)
WshShell.SendKeys ("{Enter}")
Sleep 2000 ' Pause for 2 seconds.
'
' Turn off navigation pane.
'
WshShell.SendKeys ("%d")
Sleep 100 ' Pause for 1/10 of a second.
WshShell.SendKeys ("{Tab}")
Sleep 100 ' Pause for 1/10 of a second.
WshShell.SendKeys ("{Tab}")
Sleep 100 ' Pause for 1/10 of a second.
WshShell.SendKeys ("{Down}")
Sleep 100 ' Pause for 1/10 of a second.
WshShell.SendKeys ("l")
Sleep 100 ' Pause for 1/10 of a second.
WshShell.SendKeys ("n")
'
' Establish application variable.
'
Set myShell = CreateObject("Shell.Application")
'
' Select Active Windows Explorer window.
'
For Each myExplorerWindow In myShell.Windows
On Error Resume Next
iCnt = iCnt + 1
If iCnt = myShell.Windows.Count Then
If myExplorerWindow.Parent.Name = "Windows Explorer" Then
'
' Resize and relocate Windows Explorer window.
'
myExplorerWindow.Width = 280
myExplorerWindow.Height = 820
myExplorerWindow.Top = 150
myExplorerWindow.Left = 1265
' myExplorerWindow.Visible = True
End If
End If
On Error GoTo 0
Next
'
' Quit Excel
'
Application.Quit
End Sub
--------------------------------------------

Thanks so much to everyone who assisted in this process! Very much appreciated.

RE: Resize an Application Window

I realize that some users need or want to run macros from the Extra application where they are performing their work.

However, as a screen scraper, I ran EVERYTHING from Excel VBA and had great success.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Resize an Application Window

(OP)
Absolutely, Skip!

Also, if you would like to set up an icon on the desktop in order to run the macro and disable the splash screen, then exit Excel automatically, this can be accomplished as well. You just need to know where the EXCEL.EXE file is located. The /e flag prevents the splash screen from displaying. So the icon on my desktop contains the following information:

"C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE" /e "G:\Macros\Open Client Relations Desktop Folder.xlsm"

And, as indicated above, the macro contains the line Application.Quit, which exits Excel after executing the macro.

RE: Resize an Application Window

How about a .bat file to open a specific Excel workbook. In that workbook's Workbook_Open event, run your macro, that would include closing that instance of Excel.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Resize an Application Window

(OP)
Yes, thanks, Skip!

As usual, more than one way to skin a cat, so to speak!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close