You can do this with the Auto_Open procedure in the data base workbook.
Sub Auto_Open()
MsgBox "This workbook cannot be opened manually"
ThisWorkbook.Close savechanges:=False
End Sub
Auto_Open is automatically executed when the workbook is opened manually,
not when it is opened via VBA code and so the code above closes the workbook
if it is opened manually. Of course, the user could defeat this by disabling
VBA code or by simply holding the SHIFT key down while opening the workbook.
However, this approach may be "good enough" for your purposes.
If you need code to run when the workbook is opened, either via VBA code and
manually, put that code in the Workbook_Open event in the ThisWorkbook
module. Workbook_Open is executed when the workbook is opened, regardless of
how it is opened.
--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)