views:

387

answers:

2

how do I successfully compile this code from the commandline, using csc.exe, in terms of which dll's I should reference. I would like this to work with Office 2007 as well as Office 2003.

I am use DotNet Framework SDK 2.0.

I get this compilation error:

(2,37): error CS0234: The type or namespace name 'Interop' does not exist in the namespace 'Microsoft.Office' (are you missing an assembly reference?)

using Microsoft.Office.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;

 namespace PPInterop
 {
 class Program
 {
    static void Main(string[] args)
    {
            PowerPoint.Application app = new PowerPoint.Application();
            PowerPoint.Presentations pres = app.Presentations;
            PowerPoint._Presentation file = pres.Open(@"C:\project\JavaTut1.ppt", MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
            file.SaveCopyAs(@"C:\project\presentation1.jpg", Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsJPG, MsoTriState.msoTrue);
    }
  }
 }
A: 

You need to find the paths to the dlls implementing the interfaces you reference, then look at the command-line parameters for csc.exe to learn how to add those references into your command.

John Fisher
A: 

You need to include Microsoft.Office.Interop.PowerPoint the path should be something like: C:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Microsoft.Office.Interop.PowerPoint.dll for 07 and replace Office12 with Office11 for 03 I believe

SpaceghostAli
here's an example:Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"C:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Microsoft.Office.Interop.PowerPoint.dll" /reference:"c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:"c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\Test.dll /target:library Test.cs
SpaceghostAli