tags:

views:

674

answers:

6

Hi there,

Does anyone know or can find some sample code showing how to call a WCF service using Excel 2003?

+1  A: 

This article targets accessing Web Services in Excel Using Visual Studio Tools for the Microsoft Office System, and the information should apply similarly to a WCF service.

Mitch Wheat
+1  A: 

I don't have the perfect winner for you, it's probably going to be difficult. Things got a lot better developing for Office 2007. But, given that, you should check out Visual Studio Tools for Office. Here are some examples using VSTO with Excel 2003. Here is an article on how to call WCF from an Office 2007 application. You should be able to adopt that with some success. GL. :)

JP Alioto
A: 

Thanks guys, that's a great help.

I am playing aroung with VSTO now. Great that I can do it all in C# and not have to use VBA.

Can I please ask another question.

What should I use to display the reports in Excel? I am sourcing the reports from SQL Reporting Services.

Is there a control for excel that I embed my report in and if so what format should I return the report from my WCF service or should I return the URI of the report?

+1  A: 

If you want to call WCF web services from Excel2003 and you dont want to use VSTO, you need a COM compatible option (No .Net).

Although it is Tooooootally deprecated (and uncool) you can achieve this using a basicHttpBinding on the server and the Soap Toolkit

If you dont want to do that, you may be able to do the calls using a .Net assembly and use COM Interop to call it from Excel.

Michael Dausmann
A: 

REST services also work quite nicely with Excel.
If you use the "WebHttpBinding" you can import the data to excel using File -> Open or via Import External data -> Xml.
Isn't quite perfect with 2003 though (much better with 2007).

Cwoo
A: 

You might want to look at using the WCF Service Moniker which lets you invoke a WCF Service from VBA without installing anything on the Excel client machine other than the .NET Framework.

Dim addr As String
addr = "service:mexAddress=""net.tcp://localhost:7891/Test/WcfService1/Service1/Mex"","
addr = addr + "address=""net.tcp://localhost:7891/Test/WcfService1/Service1/"","
addr = addr + "contract=""IService1"", contractNamespace=""http://tempuri.org/"","
addr = addr + "binding=""NetTcpBinding_IService1"",bindingNamespace=""http://tempuri.org/"""

Dim service1 As Object
Set service1 = GetObject(addr)

MsgBox service1.GetData(12)

I've written out a complete step-by-step example.

/Damian

Damian Mehers