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
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.