Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.dotnet.general,microsoft.public.dotnet.framework.remoting,microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.framework.interop,microsoft.public.excel.misc
external usenet poster
 
Posts: 43
Default What is the simplest IPC from Excel VBA to a .NET app?

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


  #2   Report Post  
Posted to microsoft.public.dotnet.general,microsoft.public.dotnet.framework.remoting,microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.framework.interop,microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default What is the simplest IPC from Excel VBA to a .NET app?

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.

--
Mike
  #3   Report Post  
Posted to microsoft.public.dotnet.general,microsoft.public.dotnet.framework.remoting,microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.framework.interop,microsoft.public.excel.misc
external usenet poster
 
Posts: 43
Default What is the simplest IPC from Excel VBA to a .NET app?

In article ,
Family Tree Mike wrote:
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


  #4   Report Post  
Posted to microsoft.public.dotnet.general,microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default What is the simplest IPC from Excel VBA to a .NET app?


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.


If your .NET process has a window then you can use FindWindow to find
the window handle then SendMessage to send it a message. These are
Win32 API functions, but you should be able to call them from VBA with
suitable declarations.

http://msdn.microsoft.com/en-us/libr...50(VS.85).aspx

http://msdn.microsoft.com/en-us/libr...99(VS.85).aspx

http://msdn.microsoft.com/en-us/libr...31(VS.85).aspx
  #5   Report Post  
Posted to microsoft.public.dotnet.general,microsoft.public.excel.misc
external usenet poster
 
Posts: 43
Default What is the simplest IPC from Excel VBA to a .NET app?

In article , Jamesb wrote:

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.


If your .NET process has a window then you can use FindWindow to find
the window handle then SendMessage to send it a message. These are
Win32 API functions, but you should be able to call them from VBA with
suitable declarations.

http://msdn.microsoft.com/en-us/libr...50(VS.85).aspx

http://msdn.microsoft.com/en-us/libr...99(VS.85).aspx

http://msdn.microsoft.com/en-us/libr...31(VS.85).aspx


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




  #6   Report Post  
Posted to microsoft.public.dotnet.general,microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default What is the simplest IPC from Excel VBA to a .NET app?


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.


It's actually very easy, well simpler than sockets anyway.

See here for more info:

http://social.msdn.microsoft.com/For...-a35520898005/
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
Excel 2007 very slow to open even the simplest worksheet John Excel Discussion (Misc queries) 25 July 10th 13 05:24 AM
Simplest Question James8309 Charts and Charting in Excel 2 July 21st 08 12:02 AM
What is the simplest way to do addtion of cells on reports. Elaine Excel Discussion (Misc queries) 1 April 17th 07 12:58 AM
What is the simplest way famdamly Excel Discussion (Misc queries) 4 February 16th 06 10:23 PM
What is the simplest way to print multiple worksheets? substring Charts and Charting in Excel 1 April 21st 05 11:49 PM


All times are GMT +1. The time now is 10:02 PM.

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

About Us

"It's about Microsoft Excel"