1. Home
  2. Computing & Technology
  3. Visual Basic

VBA - The Word Working Partner - Part 1

By Dan Mabbutt, About.com

2 of 7

Creating the Program

We're going to create a program that starts automatically and displays the path to the Word "startup folder". In order to do this, we're going to have to find out what the startup folder is.

Before you say, "Hey! You can just go to Tools > Options > File Locations tab and see what the startup folder is. You can also use the folder C:\Program Files\Microsoft Office\Office\Startup folder." I know that. We're doing it this way to learn how to code Word VBA programs.

First, start Word and then go to Tools > Macro > Visual Basic Editor. Click the Module option under the Insert menu. Enter this code. (Note that long lines are continued in most examples here. You can enter these lines without the continuation. I've continued them in the example code to keep the lines short.)

~~~~~~~~~~~~~~~~~~~~~~~~~
Public Sub AutoExec()
  MsgBox ("The Word Startup Folder is: " _
    & vbCrLf & Word.Application.StartupPath)
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~

Explore Visual Basic
By Category
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB 6
  5. Learn VBA
  6. VBA - The Word Working Partner - Part 1

©2009 About.com, a part of The New York Times Company.

All rights reserved.