3 Ways To Open Applications & Windows Maximized With VB Script [Windows]

Ryan Dube 27-10-2011

script to maximize a windowIf there is one thing I love to do, it’s write VB scripts. Whether it’s a Windows Script file or a VBA script inside an application, scripting provides the ability to add functionality to applications where most other people would find limitations and roadblocks.


One of the most common functions that I’ve found I use in many of my scripts is maximizing a window. This may be the launching of an application from a Windows script, or maybe launching an Excel or Word document in full-screen mode for display in a conference room, or as an application of sorts.

The beauty of scripting is that you don’t have to be a programmer to do this, and you don’t have to have any special software installed. If you’re using a Windows computer, or any application that has a VBA back-end, you can make use of these functions. In this article I’m going to provide three examples of how you can maximize windows using VB scripts, but you can take what I’m going to show you here and use it throughout any other script that you might be building.

Launch Applications In Maximized Mode

Before we get started, I’m going to quickly show you how you can launch any application in maximized mode by writing a quick script that launches that program using the Windows Shell.

There is a parameter in the Shell “Run” command where you can tell the application what mode to run in, and it will run it maximized. This is what the script looks like.

<script language="VBScript">
Option Explicit
On Error Resume Next
Dim WshShell
Dim retVal
Dim myPath 
set WshShell=CreateObject("WScript.Shell") retVal = WshShell.Run("C:\temp\firefox", 3)

You can substitute any program in the string where I currently have Firefox, and if the app allows for it. It’ll launch maximized. Some apps don’t. For example, this technique works for Firefox, but Chrome seems to have a mind of its own. Regardless, this script will work with most applications.

Open Documents Maximized in Word

To maximize any Word document, using nothing more than a command button in Word, you’ll need to enable Developer mode. To do this, click the Windows button and select Word Options at the bottom of the dropdown. In the Options menu, select “Show Developer tab in the Ribbon“.

script to maximize a window

Now you can select the Developer menu item and make use of “design mode” where you can code awesome functionality into your Word documents. To create a button that can maximize the document to full-screen, just enable Design Mode, click on the Forms dropdown button and click on the button object.

script maximize window

Place the button anywhere at all that you want in your document.  Right-click on the button, select CommandButton Object and then click View Code. Now, there are two things you can do to maximize the window. You can either force the Windows application itself to maximize like this.

Application.WindowState = wdWindowStateMaximize

Or, you can make the entire document go full-screen and remove the header toolbars completely.

ActiveWindow.View.FullScreen = True

This puts the entire document in full-screen with only a ruler enabled (if you click on the ruler button in the upper left). To get out of full-screen mode, just tap the Escape key.

script maximize window

What can this be used for? Well if you don’t have Microsoft Powerpoint, you can basically use this feature to  make use of Word as a similar display tool. To flip to the next page, you just scroll down the document.

If you don’t want to use a command button and would rather have the document automatically open in this mode, just use the code above in the Document_Open() function. You can get to that function in the code editor by selecting “Document” in the left dropdown at the top of the code window, and “Open” on the right dropdown.

Open Spreadsheets Maximized In Excel

What you can do with VBA in Word, you can usually also do in Excel, except things are going to be just a little bit different. You can enable the Developer toolbar the same way you did in Word above, but when you add a button you’ll see that Excel wants you to apply a Macro. All you have to do is name a new Macro and click on the “New” button. That will put you into the code editor.

script maximize window

This is where you’ll type the code to maximize the spreadsheet and remove the scrollbars.

script maximize

If you’re not accustomed to coding in VBA, you’ll notice that many of the objects you can reference in your code are listed to the left. You can perform a number of actions on specific sheets and workbooks, and lots of the objects inside those sheets as well. In this case you’re referencing the entire Excel application itself.

Application.DisplayFullScreen = True
Application.CommandBars("Worksheet Menu Bar").Enabled = False

You can perform a number of actions on specific sheets and workbooks, and lots of the objects inside those sheets as well. In this case you’re referencing the entire Excel application itself. This code will convert the Excel window to full screen mode and then entirely remove the menu bar at the top of the screen.

script to maximize a window

Just like in Word, you can get out of this mode with the Escape key, and you can also use the same code in the  screen. You can also use this code in the Workbook_Open() or Worksheet_Activate() functions to enable full-screen mode without the need for a button. However you want to perform your script magic is up to you!

So start up Notepad or MS Office and give these scripts a try. Did you think of some creative use for launching maximized applications? Share your experiences in the comments section below.

Image Credit: Shutterstock

Related topics: Android Launcher, Programming.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. keeneekka
    September 28, 2017 at 1:41 pm

    good gave me the answers