0

I'm trying to pass messages between a vba application (in powerpoint- during a slideshow) and a .net application I wrote.

The only method I could think of, is sending keystrokes.

However, this method causes the powerpoint to lose focus.

can you suggest a solution ?

Community
  • 1
  • 1
Uri Goren
  • 13,386
  • 6
  • 58
  • 110
  • 3
    http://damianblog.com/2009/07/05/excel-wcf/ – Robert Harvey Sep 18 '12 at 22:55
  • 4
    It's difficult to suggest a solution without knowing what you intend to do (what messages?, how often?, Based on what Event/data/time?). If you wrote the App then SendKeys is probably NOT the way forward. –  Sep 18 '12 at 22:56
  • I have a background .net application, and I'm trying to make it aware of the current powerpoint state. in otherwords - whether the slideshow is on, and what slide is shown – Uri Goren Sep 19 '12 at 05:45

2 Answers2

1

If all happens on the same machine, the easiest way maybe is to let the PPT write its status into the registry from where the other application reads it out (GetSetting(), SaveSetting()).

If PTT and the other process run on different machines, you could think of writing out the status into a small text file which can be read out asynchronously.

Another way of (synchronous) communication between two processes/applications on different machines is to use sockets and send information across the network.

MikeD
  • 8,861
  • 2
  • 28
  • 50
  • The two apps are running on the same machine, I don't like the whole concept of polling for file-system changes, because it's error-prone (permissions, etc.) – Uri Goren Sep 19 '12 at 12:58
  • in this case use `SaveSetting()` on the PPT-VBA side to push info into the registry and `=GetSetting()` to retrieve them from your other application – MikeD Sep 20 '12 at 06:52
0

I found an interesting way of communication between vba and .net, without file system manipulation, sockets or external objects.

First, We register powerpoint evets, as such:

http://www.vbaexpress.com/kb/getarticle.php?kb_id=327

Second, We update the clipboard in VBA on the presentation-start event:

http://word.mvps.org/faqs/macrosvba/ManipulateClipboard.htm

Third, We use a clipboard a listener on .net:

How do I monitor clipboard content changes in C#?

Last, We restore the original clipboard value on presentation-end event

Community
  • 1
  • 1
Uri Goren
  • 13,386
  • 6
  • 58
  • 110