Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
go to the same path of the excel file being launched Tim Excel Programming 2 April 2nd 06 04:53 PM
In Excel, why does my VB not work when launched from IE ? David C Excel Programming 3 March 21st 06 10:46 AM
XLSSTART\ does not works when Excel is launched from other application Vliegenmepper Excel Discussion (Misc queries) 1 September 15th 05 12:15 PM
How do I determine how excel was launched Gilgamesh[_2_] Excel Programming 2 January 21st 05 08:04 AM
Can you tell how Excel is launched? Gail Hurn Excel Programming 3 January 11th 05 06:47 PM


All times are GMT +1. The time now is 02:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"