Auto_Open Documentation

J

josh

I'm hard pressed to find any documentation about the use of Auto_Open and
precious little about the use of Personal.xls. Does anyone have any
suggestions.

Josh
 
S

shades

josh said:
...and precious little about the use of Personal.xls. Does anyone
have any suggestions.

What in particular are you wanting to know about Personal.xls? The
primary use is to store macros/code that will be available at all times
in all worksheets. Personal.xls is hidden. To check whether you have it
activated, go to Window > Unhide. If it is greyed out then you have not
used it. Easiest way to do this is to record a macro.

Tools > Macro > Record New Macro

Once that is done, just click the stop button (or Tools > Macro > Stopr
Recording). Then go to Window > Unhide and choose Personal.xls. It will
look like any other worksheet. But don't put anything in there. If you
want to see your recorded "macro" then Tools > Macro > VBE Editor. A
new window with Visual Basic Editor will appear, with the macro code on
the right side, and the VB Explorer window on the left.

If you don't want to do anything more, then close the VB Window. In
Excel *be sure to hide Personal.xls* again (Window > Hide). Then when
you quit Excel completely, a dialog box will ask if you want to save
changes to Personal.xls. Click OK.

If you want more info, just ask.
 
D

David McRitchie

Hi Josh,
I presume you are into macros and okay with them. If not
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Auto_Open is the name used for a macro that is run when the workbook
is opened. You would have only one macro named Auto_Open in
your workbook and it is placed in a regular module (the default module name
begins with "module"). Auto_Open in a normal module will be run later than
Workbook_Open. Workbook_Open is newer in Excel than Auto_Open
you can read about Workbok_Open in
http://www.mvps.org/dmcritchie/excel/event.htm

Personal.xls is a workbook just like any other workbook, in fact
the name itself doesn't really matter. Unlike your other workbooks
you would keep your personal.xls workbook in the XLSTART directory
which you will find in the same directory as excel.exe starts from.
This means that whenever you open Excel your personal.xls workbook
will be opened and the macros will be available to other workbooks.

If I had not glanced to see if there were other replies, I would have
forgotten to mention the part about hiding your personal.xls workbook
If you do not hide the workbook the macros are only automatically
available in the same workbook. The purpose of your personal.xls
workbook is just as a repository for macros and UDF, you would not
want to be using worksheets in that file. You are required to have
one worksheet in a workbook, so that worksheet should really be empty.
Look for "hide" in http://www.mvps.org/dmcritchie/excel/formula.htm
along with more information on macros and user defined functions.

When you record a macro, you have the option of creating it in
your personal.xls, and if you don't have a personal.xls, then Excel
will create it for you in the proper directory.

In tools, options, general there are two places to specify directories
Default file location: This is where new files would be created by
default. This will override where Excel would place them. It is
fine to specify your own default directory, it should nol be in your
XLSTART directory as that would open the workbook everytime
Excel starts which would not be good.
Alternate startup file location: Unless you are on a network and your
administrator has given instructions otherwise, almost everyone
should leave this area empty. A directory specified here will be the
same as placing files in your XLSTART directory -- Excel will open
the files in the directory at startup.

One rather frustrating difference between invoking macros and invoking
user defined functions (UDF) even though both may be in your personal.xls
is that macros can be called by name from any open workbook without
having to specify the workbook and will show up in Alt+F8 list of
macros. Functions do not show in same list of macros, you will find
your UDF can be found in the Paste Function Wizard [fx] on your toolbar,
look for "User Defined" on the left side ("Function category") then for
the function names on the right side of the Paste Function Wizard.
In order to use a UDF from another workbook you must either specify
the workbook and the function, or make provision for automatic references.
http://www.mvps.org/dmcritchie/excel/getstarted#udf

You might also look at some of the tutorials on my Excel home page.
http://www.mvps.org/dmcritchie/excel/excel.htm#tutorials

HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm
 
N

Norman Harker

Hi Josh!

Here's something I put together on Personal.xls

The Personal.xls file is both a normal file and a special one. It is
‘normal’ because it has the same structure and facilities as any other
workbook. It is ‘special’ because Excel can create it and it is most
often used for special purposes by users who go beyond the
intermediate stage and start to write their own subroutines and
functions.



The Personal.xls file, if it exists, is usually loaded by Excel every
time that you start Excel. If it exists, it sits in the XLSTART folder
(aka directory). In multi-user set-ups in Windows XP and Windows 2000,
each user has their own Personal.xls file. What’s all this ‘if it
exists’ about?



When you create your first Macro / Subroutine, you are given the
option of saying where you want to put it. One of those options is
“Personal Macro Workbook.” If you select that option, Excel will
create the Personal.xls file and when you save it, it will be saved in
the XLSTART folder / directory. Thereafter, every time you start Excel
the Personal.xls file will be loaded (as will any other files that are
sitting in the XLSTART folder).



You don’t usually see the Personal.xls file. It is loaded as a hidden
workbook. But if it is loaded you can establish its existence and
unhide it using:



Window > Unhide [There will then be an “Unhide” dialog and if the
personal.xls file exists, it will be listed.]

Cancel



But it is not usually a good idea to unhide the Personal.xls file. You
should only unhide it if you want to place material on the worksheets
that are in the Personal.xls file



**What is the Personal.xls Used For?



The Personal.xls file can be used for various things. You might use it
to:



1. Establish your favoured settings or ‘defaults’ so that if any
“foreign” or special workbook has altered them, you can get them back
by the simple expedient of closing and re-opening Excel.

2. Create special functions (User Defined Functions) that do special
calculations that aren’t easily done by Excel’s existing functions or
which require complex processes to achieve by normal operations in a
workbook.

3. Create special subroutines (aka ‘macros’) that do things that
cannot be achieved by formulas or functions such as alter the format
of a cell or send an e-mail or set up standard print options like
headers and footers or …the list is almost limitless.

4. Create or modify special commandbars (aka ‘toolbars’ and ‘menubars
’) with or without your own special buttons, which insert formulas or
functions or which trigger a particular subroutine.

5. Create new keyboard shortcuts that trigger a subroutine or to
assign a new context sensitive mouse right click menu option.

6. Create powerful event handling subroutines that get triggered
whenever a particular event occurs such as opening a new workbook.

7. Test functions and subroutines before turning them into or
incorporating them into an existing or new workbook or Add-In.

8. Personal base data may be stored on one of the worksheets within
the Personal.xls but I haven’t seen that mentioned anywhere.

9. John Walkenbach uses a special procedure for building up
hierarchical menus from worksheet information and if you follow that
approach, the data may be kept on a worksheet in the Personal.xls.



For many Excel advanced users it can a varied box of tricks. Here’s
what Jon Peltier MVP said in the microsoft.public.excel.programming
newsgroup in response to a question “What's in your personal.xls
file?” on 9-Jan-2002:


Start Quote from Jon Peltier>>



“In addition to many half written bits and pieces, I have several
crucial things in my personal.xls workbook. First is the code that
constructs my custom command bars. My various paste special buttons
(paste values, paste values transposed, paste formulas, paste as
picture plus copy as picture for charts). The button to center across
the selected cells (like Excel 95; I don't like merging cells if I can
avoid it). The button with the special border styles I like, the code
to fix up any chart the way I like and some other charting things, one
to lock or unlock all sheets in the workbook, the ones that increase
and decrease zoom by 5 percentage points. The screen saver (an API
deal). The custom print setup routine, the text change case routine.
The very important one that lists all defined names in a workbook.
Another that breaks the hyperlinks (from a web page loaded into
Excel). Some things that perform rounding or truncate to integers, or
fill linearly or logarithmically the range between two cells, or fill
blank cells from the previous value above. Some statistics, some
rudimentary cryptography, some file renaming stuff, a lot of little
things called "test()" or "testme()" etc.



The sucker's around 600k, and between it and the addins I use, it
takes 20 or so seconds to load Excel. I'm thinking of breaking it
down into a few addins (charting, formatting, whatever) so I only need
to load what I need at that time.”



<<End Quote from Jon Peltier



And as I’ve done a ‘show and tell’ with Jon Peltier it is only fair to
admit to what I have in mine!

Sub ApostroRemove()

Sub Beeper()

Sub CentreAlign()

Sub CharMap()

Sub DateTimeStamp()

Sub EquationEditor()

Sub FormatComments()

Sub InsertDate()

Sub InsertTime()

Sub LeftAlign()

Sub LISTENVIRON()

Sub makelastcell()

Sub MergeLeftTopWrap()

Sub PrintBy()

Sub ProtectAllSheets()

Sub RightAlign()

Sub SaveAllFiles()

Sub ShowCommandBarNames()

Sub UnhideAllSheets()

Sub UnprotectAllSheets()



But most of my UDFs are put in a special Functions Add-In which is
updated as soon as it is reasonably established that the function
works as it is supposed to. I also have a tendency to run major new
tests in separate files so that I don’t get too much accumulated stuff
in my Personal.xls.

***Creating a Personal.xls

It’s handy to have the Personal.xls in existence ready for use
immediately you want it.



First establish that you don’t already have one (under the current
user log-in if appropriate):



Window > Unhide [check there isn’t a PERSONAL.XLS entry]

Cancel



Open a new workbook [Just so you don’t damage anything you have]

Tools > Macro > Record New Macro [Up pops the Record Macro dialog]

Click dropdown arrow for “Store Macro In:”

Select “Personal Macro Workbook”

OK

Tools > Macro > Stop Recording



If you now open the Visual Basic Editor you will find that you now
have a Personal.xls file:



Alt + F11 [Opens the Visual Basic Editor]



In top left box you’ll see, possibly among other listings, an entry:



Personal (PERSONAL.XLS)



Expand the tree and you’ll find under Modules that you have a Module1
that contains whatever you recorded between pressing OK in the above
procedure and stopping the recording process.



Select the Personal(PERSONAL.XLS) entry

File > Save



You now have a saved Personal.xls file and you can check that it now
exists using the Window > Unhide > Cancel process.

***Finding the Personal.xls File

**Windows 95, 98 and ME

The Personal.xls file is usually pretty easy to locate:



C:\Program Files\Microsoft Office\Office\XLStart



But note at this point that there isn’t always a Personal.xls file and
it can be a hidden file.



There are minor variations such as different Drive or non-standard
installation or Office10 being the folder under Microsoft Office but
these aren’t really too much of a problem. So this isn’t always the
case and is only to be regarded as the “usual” case.

**Windows 2000 and Windows XP



There is a facility for all users to have their own Personal.xls and
that this indeed is the unwritten rule. That makes finding the
Personal.xls a little more difficult. It's perhaps useful to note two
easy ways to finding the "current" Personal.xls file are:
**Excel Approach
Open up Excel (if you can!)

Windows > Unhide

*Note* here that you might not have a Personal.xls file and if it's
not listed in the Unhide dialog you've establish this fact and can now
stop all further processes of trying to find it. Otherwise continue:

Select Personal.xls
The Personal.xls should be active workbook now and appear in the Title
Bar.
Then in A1 use:

=INFO("directory")

That should give the path to the Personal.xls for this session.
Copy and paste to Word or even write it down (remember pen and paper?)
Delete A1
Windows > Hide
Close Excel
If you get asked whether you want to save changes to the Personal.xls
just say, "No!"

That should give the path to the Personal.xls for this session.

Off to Explorer and follow the path you've found and move Personal.xls
out of the XLSTART folder pending establishing whether you need to
delete it. If you don't see it there, it's because it is a hidden file
and you will need to use the option of displaying hidden files. Tools
Folder Options (View Tab)


**Explorer Approach

Cutting out the use of Excel is another option that is really the best
(especially if Excel won't boot up <vbg>)

Start > Shut Down [I mean, how else would you stop but by
pressing the Start button?]
Click the drop down box of options
Note and remember who you can Log Off
Click Cancel

Right click the Start button to active Windows Explorer
Now you'll find the current user's Personal.xls in:

C:\Documents and Settings\*Who was logged on*\Application



Data\Microsoft\Excel\XLSTART

But note that the Personal.xls may be a hidden file and that it might
not exist if the current user has never created it. You might find the
drive letter is different from C: if you have a non-standard
installation.

I think that's pretty definitive as a guide but there may be other
ideas and suggestions.

***Opening Without the Personal.xls



The Personal.xls file can be the source of many problems. A quick way
to check this out is to open without that file. First we can
investigate whether problems *may* relate to the Personal.xls file.



Use:



Start > Run "C:\Program Files\Microsoft Office\Office\Excel.exe"
/Automation



[Quotes mandatory, But you may have to change the path depending on
where Excel is installed. You must have the space before the /]

That starts Excel without the Personal.xls or any Addins. So if
problems have gone away, then there *may* be a problem with the
Personal.xls file, other files opened on normal opening of Excel or
with an Add-In that is loading when Excel is started. If Excel still
has problems then all we can say is that it *may* relate to the
Personal.xls file and we need to check out that file.




--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
J

josh

My thanks to Norman Harker, shades>, and David McRitchie for their very
helpful and complete answers. I would only hope that those responsible for
the HELP documentation for Excel's Visual Basic Editor might incorporate it
in their product.

Josh


David McRitchie said:
Hi Josh,
I presume you are into macros and okay with them. If not
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Auto_Open is the name used for a macro that is run when the workbook
is opened. You would have only one macro named Auto_Open in
your workbook and it is placed in a regular module (the default module name
begins with "module"). Auto_Open in a normal module will be run later than
Workbook_Open. Workbook_Open is newer in Excel than Auto_Open
you can read about Workbok_Open in
http://www.mvps.org/dmcritchie/excel/event.htm

Personal.xls is a workbook just like any other workbook, in fact
the name itself doesn't really matter. Unlike your other workbooks
you would keep your personal.xls workbook in the XLSTART directory
which you will find in the same directory as excel.exe starts from.
This means that whenever you open Excel your personal.xls workbook
will be opened and the macros will be available to other workbooks.

If I had not glanced to see if there were other replies, I would have
forgotten to mention the part about hiding your personal.xls workbook
If you do not hide the workbook the macros are only automatically
available in the same workbook. The purpose of your personal.xls
workbook is just as a repository for macros and UDF, you would not
want to be using worksheets in that file. You are required to have
one worksheet in a workbook, so that worksheet should really be empty.
Look for "hide" in http://www.mvps.org/dmcritchie/excel/formula.htm
along with more information on macros and user defined functions.

When you record a macro, you have the option of creating it in
your personal.xls, and if you don't have a personal.xls, then Excel
will create it for you in the proper directory.

In tools, options, general there are two places to specify directories
Default file location: This is where new files would be created by
default. This will override where Excel would place them. It is
fine to specify your own default directory, it should nol be in your
XLSTART directory as that would open the workbook everytime
Excel starts which would not be good.
Alternate startup file location: Unless you are on a network and your
administrator has given instructions otherwise, almost everyone
should leave this area empty. A directory specified here will be the
same as placing files in your XLSTART directory -- Excel will open
the files in the directory at startup.

One rather frustrating difference between invoking macros and invoking
user defined functions (UDF) even though both may be in your personal.xls
is that macros can be called by name from any open workbook without
having to specify the workbook and will show up in Alt+F8 list of
macros. Functions do not show in same list of macros, you will find
your UDF can be found in the Paste Function Wizard [fx] on your toolbar,
look for "User Defined" on the left side ("Function category") then for
the function names on the right side of the Paste Function Wizard.
In order to use a UDF from another workbook you must either specify
the workbook and the function, or make provision for automatic references.
http://www.mvps.org/dmcritchie/excel/getstarted#udf

You might also look at some of the tutorials on my Excel home page.
http://www.mvps.org/dmcritchie/excel/excel.htm#tutorials

HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

I'm hard pressed to find any documentation about the use of Auto_Open and
precious little about the use of Personal.xls. Does anyone have any
suggestions.

Josh
 
D

David McRitchie

Hi Josh,
You're welcome. The documentation is the HELP file, often
once you know the answers you can find it in HELP and that might
help a lot for the next time. But the newsgroups and the personal
documentation on many websites provide comprehensive
documentation that I doubt that you would ever see otherwise.

HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

josh said:
My thanks to Norman Harker, shades>, and David McRitchie for their very
helpful and complete answers. I would only hope that those responsible for
the HELP documentation for Excel's Visual Basic Editor might incorporate it
in their product.

Josh


David McRitchie said:
Hi Josh,
I presume you are into macros and okay with them. If not
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Auto_Open is the name used for a macro that is run when the workbook
is opened. You would have only one macro named Auto_Open in
your workbook and it is placed in a regular module (the default module name
begins with "module"). Auto_Open in a normal module will be run later than
Workbook_Open. Workbook_Open is newer in Excel than Auto_Open
you can read about Workbok_Open in
http://www.mvps.org/dmcritchie/excel/event.htm

Personal.xls is a workbook just like any other workbook, in fact
the name itself doesn't really matter. Unlike your other workbooks
you would keep your personal.xls workbook in the XLSTART directory
which you will find in the same directory as excel.exe starts from.
This means that whenever you open Excel your personal.xls workbook
will be opened and the macros will be available to other workbooks.

If I had not glanced to see if there were other replies, I would have
forgotten to mention the part about hiding your personal.xls workbook
If you do not hide the workbook the macros are only automatically
available in the same workbook. The purpose of your personal.xls
workbook is just as a repository for macros and UDF, you would not
want to be using worksheets in that file. You are required to have
one worksheet in a workbook, so that worksheet should really be empty.
Look for "hide" in http://www.mvps.org/dmcritchie/excel/formula.htm
along with more information on macros and user defined functions.

When you record a macro, you have the option of creating it in
your personal.xls, and if you don't have a personal.xls, then Excel
will create it for you in the proper directory.

In tools, options, general there are two places to specify directories
Default file location: This is where new files would be created by
default. This will override where Excel would place them. It is
fine to specify your own default directory, it should nol be in your
XLSTART directory as that would open the workbook everytime
Excel starts which would not be good.
Alternate startup file location: Unless you are on a network and your
administrator has given instructions otherwise, almost everyone
should leave this area empty. A directory specified here will be the
same as placing files in your XLSTART directory -- Excel will open
the files in the directory at startup.

One rather frustrating difference between invoking macros and invoking
user defined functions (UDF) even though both may be in your personal.xls
is that macros can be called by name from any open workbook without
having to specify the workbook and will show up in Alt+F8 list of
macros. Functions do not show in same list of macros, you will find
your UDF can be found in the Paste Function Wizard [fx] on your toolbar,
look for "User Defined" on the left side ("Function category") then for
the function names on the right side of the Paste Function Wizard.
In order to use a UDF from another workbook you must either specify
the workbook and the function, or make provision for automatic references.
http://www.mvps.org/dmcritchie/excel/getstarted#udf

You might also look at some of the tutorials on my Excel home page.
http://www.mvps.org/dmcritchie/excel/excel.htm#tutorials

HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

I'm hard pressed to find any documentation about the use of Auto_Open and
precious little about the use of Personal.xls. Does anyone have any
suggestions.

Josh
 
N

Norman Harker

Hi Josh & David!

I'll buy that! If you did have very full documentation in Help, you'd
spend a long time trying to find the particular piece of important
data you wanted. Better for help to give the basics and then rely on
websites / newsgroups / Google Searching to find answer to specific
"finer" points.

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 

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