Hi,
I am starting my macro off with:
dlganswer = Application.Dialogs(xlDialogOpen).Show
This allows the user to pick which file they would like to open. My
problem, however, is trying to switch back and forth between my
workbooks. If I knew the specific name of the workbook (if it was
always the same), I could just write:
windows("name of file").activate
But how to I do this when I don't know the name of the file they will
open?
I have tried things like:
windows.dlganswer.activate
but it doesn't work. Put simply, is there a way to fetch the file
name? Please keep in mind I'm a beginner. Thanks!
Thanks!
Steve Gerrard - 31 Aug 2004 08:42 GMT
| Hi,
|
[quoted text clipped - 20 lines]
|
| Thanks!
dlganswer will return simply True or False, depending on whether the
dialog completed or was cancelled.
If it succeeds, the newly opened file will become the active workbook. I
would suggest using workbooks rather than windows to control excel.
So, if dlganswer is True, then ActiveWorkbook will be the workbook just
opened. You can retrieve its name using
wbName = ActiveWorkbook.Name
You can later reactive it using
Workbooks(wbName).Activate