Do I understand correctly what you want to do? You have two workbooks open.
You designate one of them as MyName. MyName is minimized, saved, and closed.
The other workbook is left open as the active workbook. As far as I can tell,
the following code accomplishes all that. It doesn't matter which of the two
workbooks has the macro or which workbook is active when you run it. You just
have to assign the name of the workbook (as it appears in the title bar) to
the string variable MyName.
Public Sub Shrink()
'Activate the workbook to be minimized
Workbooks(MyName).Activate
'Windows(1) ia always the active window
Windows(1).WindowState = xlMinimized
'Maximize the active window
ActiveWindow.WindowState = xlMaximized
'Save & close MyName
Workbooks(MyName).Close SaveChanges:=True
End Sub
I'm not sure why you want to go to the extra trouble of miinimizing a
workbook, if you are going to immediately close it anyway.
Hutch
Hi Hutch
Many thanks for the response.
Yes, your understanding is correct.
I have two WBs open.
Both contain much data.
I use the 2 in conjunction, switching between them.
I reach a point when I need to save & close one.
Because the time it takes to save (either) is considerable (10 - 15
seconds),
I would like it to do it's saving "in the background", or "off screen",
and while that's going, look at the other (active) WB.
I agree your suggested should do what is required,
but it still seems to ignore the minimise statement until the save is
finished.
I'm still playing with it.
donwb
> Do I understand correctly what you want to do? You have two workbooks
> open.
[quoted text clipped - 89 lines]
>> >> >> Is this just syntax, or am I trying the impossible?
>> >> >> donwb
Tom Hutchins - 15 Apr 2008 21:18 GMT
I don't think I tested with a large enough file, so I made a big workbook.
When I run the macro, it seems to minimize the intended workbook, but then
un-minimize it while it saves it. In any case, I don't think you can save a
workbook "in the background" while you work with another workbook in the same
instance of Excel. Maybe it could work if the workbooks were opened in
separate sessions (instances) of Excel, but then it would be harder to
manipulate the workbook in the other session programmatically.
Hutch
> Hi Hutch
>
[quoted text clipped - 108 lines]
> >> >> >> Is this just syntax, or am I trying the impossible?
> >> >> >> donwb
donwb - 15 Apr 2008 23:19 GMT
Hi Hutch
Yes. I did find the same. The un-minimising while the save occurs.
That lead me to your conclusion - I can't do what I'm trying to do in the
same instance of Excel.
As someone who posts answers in this Forum once said,
"Sometimes the dragon wins"
Thanks for your help.
donwb
>I don't think I tested with a large enough file, so I made a big workbook.
> When I run the macro, it seems to minimize the intended workbook, but then
[quoted text clipped - 127 lines]
>> >> >> >> Is this just syntax, or am I trying the impossible?
>> >> >> >> donwb