How to determine if an excel Excel was open by code (automation) ormanually, by a human user

  • Thread starter Thread starter Radu
  • Start date Start date
R

Radu

Hi. An excel file is opened by people, but also by code from a VB
application.

I would like the code in Workbook_Open to run whenever the file is
opened by a human, but not to run when the file is opened by
automation.

Any ideas ?

Thank you very much
Alex.
 
hi, Radu !
Hi. An excel file is opened by people, but also by code from a VB application.
I would like the code in Workbook_Open to run whenever the file is opened by a human
but not to run when the file is opened by automation.
Any ideas ?

(i.e.)

Private Sub Workbook_Open()
If Not Application.UserControl Then Exit Sub
' here your normal actions ...'
End Sub

hth,
hector.
 
In the code that will open the file (by automation) bracket the file open
command with:
Application.EnableEvents=False
'your file open command goes here
Application.EnableEvents=True
HTH Otto
 
Wow ! Great tips, guys ! Thanks a lot - tomorrow I'll try both
solutions - first thing in the morning.

Thanks again, and have a great day !
Radu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top