PC Review


Reply
Thread Tools Rate Thread

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

 
 
Radu
Guest
Posts: n/a
 
      21st Jul 2008
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.
 
Reply With Quote
 
 
 
 
Héctor Miguel
Guest
Posts: n/a
 
      21st Jul 2008

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.


 
Reply With Quote
 
Otto Moehrbach
Guest
Posts: n/a
 
      21st Jul 2008
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
"Radu" <(E-Mail Removed)> wrote in message
news:68cd9bdd-72a6-4a4a-bf17-(E-Mail Removed)...
> 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.



 
Reply With Quote
 
Radu
Guest
Posts: n/a
 
      22nd Jul 2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Automation - Determine the Columns Selected Shaw Microsoft Dot NET 0 8th Jan 2009 07:54 AM
Automation C++ code works for Excel 2003, not for Excel 2007 jayo Microsoft Excel Programming 0 6th Aug 2008 06:51 PM
Access automation leaves Excel open which in turn locks 2nd automation attempts EagleOne@discussions.microsoft.com Microsoft Access 8 30th Jun 2008 01:27 AM
automation on excel(automated from Access VBA code) stops when opening another excel file thread Microsoft Access 1 27th Apr 2007 09:07 PM
Excel Automation Code Fails To Quit Excel MikeC Microsoft Access VBA Modules 2 2nd Nov 2005 05:38 PM


Features
 

Advertising
 

Newsgroups
 


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