Excel 2003 VBA - "Maximizing" Window & "Calculating" Workbook

J

JingleRock

I have a macro with 10 modules stored in an .xlA file (this is not
installed in Excel using Tools - Add-Ins). The purpose of Module 1 is
to open, on each business day, a workbook (it has only one worksheet
with zero formulas, only strings and numbers; the preceding day's
version is replaced), make a few minor changes, and save it to a shared
drive (same path as the file that was opened); also, this file is
attached to an Outlook e-mail and sent to an user group. It is
desirable that when users open the e-mail and open the attachment, that
the window be "maximized"; also, it is desirable that the shared drive
workbook window be "maximized" when it is opened using Windows Explore
and that, when both of these workbooks are shut down without the user
having made any changes, that the user not receive the pop-up question
- "Do you want to save the changes you made ...?".

In the 'ThisWorkbook' module of my .xlA file, I have the following
code:

Option Explicit
Private Sub Workbook_Open()
Application.WindowState = xlMaximized
End Sub

Near the end of Module 1, I have the following code:

ActiveWindow.WindowState = xlMaximized
Application.Calculate
SaveWorkBook oWBookOutPut

The following applies to both the e-mail attachment and to the file
stored on the shared drive:
I am getting inconsistent results; most of the time, the new workbook
opens in "xlNormal" size. Sometimes I am getting the "Do you want to
save ...?" prompt and sometimes not when shutting down the file without
making any changes; furthermore, when viewing the question prompt and
selecting "No", and then re-opening each of the workbooks, sometimes I
will not get the question prompt -- subsequent re-openings behave
exactly the same.

Lastly, I exported Module 1 and made it a freestanding macro. It
behaves perfectly each time I run it. Does anyone have any ideas as to
what is happening?

Thanks for a response,
JingleRock
 

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