0

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 .Net 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?)

Source code:

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);
    }
  }
 }

2 Answers 2

0

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.

0

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

1
  • 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
    – HasaniH
    Jul 2, 2009 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.