View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
John Coleman John Coleman is offline
external usenet poster
 
Posts: 274
Default How to get known by which application Excel was launched?

Hi,

In addition to Bill's registry idea - you can store a flag as a hidden
name in the workbook's Names collection. Here is some idea of how to do
it:

First, decide on a name for the flag (say "status") and a prelimnary
value (say "updated")

Then run the following code in the workbook just once:

Sub AddName()
ActiveWorkbook.Names.Add "status", "updated", False
End Sub

The "False" refers to visibility, so that the name does not appear in
the names dialogue box.

The following snippet shows how to access the contents of the flag:

Sub CheckStatus()
MsgBox Evaluate(ActiveWorkbook.Names("status").RefersTo)
End Sub

Finally, the following shows how the flag can be turned on and off:

Sub ToggleStatus()
If Evaluate(ActiveWorkbook.Names("status").RefersTo) = "updated" Then
ActiveWorkbook.Names("status").RefersTo = "not updated"
Else
ActiveWorkbook.Names("status").RefersTo = "updated"
End If
End Sub

The main drawback to this approach is that the workbook must be saved
for any change in the flag to persist - but if you are opening the
workbook, processing it in some fashion and then closing it, this
presumably isn't a problem.

Hope that helps

-John Coleman

Sergiy wrote:
Dear Colleagues,

I am trying to automate some reports fuctionality by excel macro and I
need to avoid double processing for the expored data .

I wrote add-in excel modute to hook the workbook open event. Than if it
found certain named range it processing exported data.

The problem is that my macro runs every time when workbook with this
named range opens and performs data processing and so modify some
important data (for example when report was created).

I need some marker to get know that this workbook was updated by main
programm and need to be processed.

Or I need to get know that excel was started by main application and
perform data processing in this case and ignore all other cases.

Do you have any Idea how it can be implemented?