I posted this in the office forum, too...
Background info: I have several external data ranges in my excel workbook and it contains two worksheets. Each data range is automatically refreshed on file open and is associated with queries that provide data based on the user's login (e.g. select * from whatever where loginfield=suser_sname()--> suser_sname() is just a function that retrieves the login of the person on the machine).
Anyway, my problem is that a SQL Server error occurs if a user who is not allowed access to SQL Server opens my workbook. So, I would like to trap the error and kindly kick the user out. As far as I can tell, the error happens as soon as a data range tries to refresh. But, I can't seem to figure out which event is associated with this, i.e. where do I place the error-trapping code?
Much Thanks!
Background info: I have several external data ranges in my excel workbook and it contains two worksheets. Each data range is automatically refreshed on file open and is associated with queries that provide data based on the user's login (e.g. select * from whatever where loginfield=suser_sname()--> suser_sname() is just a function that retrieves the login of the person on the machine).
Anyway, my problem is that a SQL Server error occurs if a user who is not allowed access to SQL Server opens my workbook. So, I would like to trap the error and kindly kick the user out. As far as I can tell, the error happens as soon as a data range tries to refresh. But, I can't seem to figure out which event is associated with this, i.e. where do I place the error-trapping code?
Much Thanks!