Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to identify if a workbook was opened by another workbook

Status
Not open for further replies.

James1981

Programmer
Nov 2, 2002
76
0
0
US
Hi,

I have a workbook which I open using a macro, and I need to tell whether the workbook has been opened by the macro (in the first workbook) or by the user manually...

Is there an easy way of doing this within the Workbook_Open() method

Thanks,

James
 
You'd have to have some flag in each of your workbooks. The flag could be either an unused cell, e.g. in a hidden worksheet, or a member of the names collection for the workbook. The workbook_open handler would reset the flag. Then the macro doing the opening could set the flag after the workbook has been opened. Now the flag will be set if it was opened by macro, reset if opened by user. But this approach requires that all workbooks have this functionality built in. If that's not acceptable, you'll have to keep track of the workbooks in the workbook containing your macro. That may be preferable anyway.


Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top