Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to get known by which application Excel was launched?
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? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to get known by which application Excel was launched?
If you only have a single instance at any given time, you can set a status
flag in the registry. Before an application calls / opens excel, set the registry key to "pending" (or some equivalent), then the workbook code can check the registry value (in addition to looking for the named range). When you've completed operations, set the registry key "complete". If you had multiple instances running, you can use a queue (via ini or log file, or in the registry) that keeps track of all your requests and updates the queue when the requested operations are completed. Bill "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? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
go to the same path of the excel file being launched | Excel Programming | |||
In Excel, why does my VB not work when launched from IE ? | Excel Programming | |||
XLSSTART\ does not works when Excel is launched from other application | Excel Discussion (Misc queries) | |||
How do I determine how excel was launched | Excel Programming | |||
Can you tell how Excel is launched? | Excel Programming |