ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Database Workbook (https://www.excelbanter.com/excel-programming/415245-database-workbook.html)

ranswrt

Database Workbook
 
I have a Database workbook that is opened by other workbooks to access the
data in it. Is it possible to make the database workbook so that it can only
be opened thru antoher workbook and not by clicking on the icon?

Chip Pearson

Database Workbook
 
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)



"ranswrt" wrote in message
...
I have a Database workbook that is opened by other workbooks to access the
data in it. Is it possible to make the database workbook so that it can
only
be opened thru antoher workbook and not by clicking on the icon?




All times are GMT +1. The time now is 01:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com