 |
|
| .NET DotNet Forum Index » General Discussion » What is the simplest IPC from Excel VBA to a .NET app?... |
|
Page 1 of 1 |
|
| Author |
Message |
| John Brock... |
Posted: Sat Nov 07, 2009 4:02 pm |
|
|
|
Guest
|
What is the simplest way for VBA code (in Excel) to send some sort
of signal to a .NET process and tell it to do something? The VBA
code knows the task ID of the .NET process, because it started that
process (a Windows Forms app) using Shell(). It isn't necessary
to pass any information either way (although that wouldn't hurt);
all that is needed is a way to poke at the .NET process so that it
wakes up and looks for an instruction file that has just been
written by Excel.
Right now the .NET process is polling the disk, looking for new
instruction files. This actually works fine, but since there can
be long intervals between new instruction files, it would be better
if there were some way for Excel to notify the .NET process directly
when a new file is written. I'm sure there's a way to do this
using sockets and threads, but I'd like to add as little complexity
as possible, so if anyone knows a simpler way I hope you will let
me know about it.
--
John Brock
jbrock at (no spam) panix.com |
|
|
| Back to top |
|
|
|
| Family Tree Mike... |
Posted: Sat Nov 07, 2009 9:15 pm |
|
|
|
Guest
|
John Brock wrote:
Quote: What is the simplest way for VBA code (in Excel) to send some sort
of signal to a .NET process and tell it to do something? The VBA
code knows the task ID of the .NET process, because it started that
process (a Windows Forms app) using Shell(). It isn't necessary
to pass any information either way (although that wouldn't hurt);
all that is needed is a way to poke at the .NET process so that it
wakes up and looks for an instruction file that has just been
written by Excel.
Right now the .NET process is polling the disk, looking for new
instruction files. This actually works fine, but since there can
be long intervals between new instruction files, it would be better
if there were some way for Excel to notify the .NET process directly
when a new file is written. I'm sure there's a way to do this
using sockets and threads, but I'd like to add as little complexity
as possible, so if anyone knows a simpler way I hope you will let
me know about it.
How is the .Net process polling, currently? If you are just testing for
a file existence, then I think you should try FileSystemWatcher on the
..net side.
I'm sure there is a way for Excel to signal the external app, but the
process sound more or less independent.
--
Mike |
|
|
| Back to top |
|
|
|
| John Brock... |
Posted: Sun Nov 08, 2009 12:02 pm |
|
|
|
Guest
|
In article <#KFrRlBYKHA.872 at (no spam) TK2MSFTNGP05.phx.gbl>,
Family Tree Mike <FamilyTreeMike at (no spam) ThisOldHouse.com> wrote:
Quote: John Brock wrote:
What is the simplest way for VBA code (in Excel) to send some sort
of signal to a .NET process and tell it to do something? The VBA
code knows the task ID of the .NET process, because it started that
process (a Windows Forms app) using Shell(). It isn't necessary
to pass any information either way (although that wouldn't hurt);
all that is needed is a way to poke at the .NET process so that it
wakes up and looks for an instruction file that has just been
written by Excel.
Right now the .NET process is polling the disk, looking for new
instruction files. This actually works fine, but since there can
be long intervals between new instruction files, it would be better
if there were some way for Excel to notify the .NET process directly
when a new file is written. I'm sure there's a way to do this
using sockets and threads, but I'd like to add as little complexity
as possible, so if anyone knows a simpler way I hope you will let
me know about it.
How is the .Net process polling, currently? If you are just testing for
a file existence, then I think you should try FileSystemWatcher on the
.net side.
I'm sure there is a way for Excel to signal the external app, but the
process sound more or less independent.
Definitely an improvement! (And it probably would have taken me
hours of plowing through the .NET documentation before I stumbled
across that class, so thanks!).
Unfortunately the sequence of events the .NET process receives from
FileSystemWatcher varies -- in a not always intuitive way --
depending to how the watched file is updated. (E.g., if I create
the file using "Save As..." in Notepad the sequence is Created,
Deleted, Created, Changed, Changed). This makes it difficult for
me to determine in a completely general way when the file is ready
to be read.
I can get around this of course by writing the file under a different
name and then renaming it. I'm still hoping though to find some
easy way to use the task ID to directly signal the .NET process
from Excel, or even pass it a string. But if I can't then
FileSystemWatcher it is.
--
John Brock
jbrock at (no spam) panix.com |
|
|
| Back to top |
|
|
|
| John Brock... |
Posted: Mon Nov 09, 2009 12:42 pm |
|
|
|
Guest
|
In article <hd9vu7$58s$1 at (no spam) aioe.org>, Jamesb <spam at (no spam) gmail.com> wrote:
Thanks. Looks interesting, but possibly overcomplicated for what
I'm doing.
Do you know what the .NET process needs to do to receive messages?
The process does have a window, but I'm not finding much information
about using SendWindow with .NET.
--
John Brock
jbrock at (no spam) panix.com |
|
|
| Back to top |
|
|
|
| Jamesb... |
Posted: Mon Nov 09, 2009 4:01 pm |
|
|
|
Guest
|
|
| Back to top |
|
|
|
| Jamesb... |
Posted: Mon Nov 09, 2009 5:59 pm |
|
|
|
Guest
|
|
| Back to top |
|
|
|
|
|
All times are GMT - 5 Hours
The time now is Fri Dec 04, 2009 2:36 pm
|
|