Reputation: 316
For reasons that are too hideous to mention I would like to be able to do MS Office Automation under Wine. However the noddy program below fails to get the document object from the instance of WinWord, though the document has been successfully opened by WinWord running under wine.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Interop.Word;
// This code is lifted from http://www.dotnetperls.com/word
namespace WordTest
{
class Program
{
static void Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine("Usage WordTest word.doc");
return;
}
String docname = args[0];
try
{
Application application = new Application();
Document document = application.Documents.Open(docname);
// Loop through all words in the document. (We get an exception here)
int count = document.Words.Count;
for (int i = 1; i <= count; i++)
{
// Write the word.
string text = document.Words[i].Text;
Console.WriteLine("Word {0} = {1}", i, text);
}
// Close word.
application.Quit();
}
catch (Exception e)
{
Console.WriteLine("Exception {0}\nStacktrace\n{1}", e.Message, e.StackTrace);
}
}
}
}
The thing I am attempting use this stuff for (not the simple code above) can't be done using OpenOffice or Apache POI etc, etc.
Any ideas?
This might be relevant:
The version of .NET this application is built for is 2
Version of WinWord is 2007
Version of wine is wine-1.5.6
Distribution of linux is openSUSE 12.2
Linux version 3.4.47-2.38-desktop #1 SMP PREEMPT Fri May 31 20:17:40 UTC 2013 (3961086) x86_64 x86_64 x86_64 GNU/Linux
Cpu Intel(R) Core(TM)2 Duo CPU T9400 @ 2.53GHz
Upvotes: 3
Views: 728
Reputation: 2304
This is a known bug in Wine.
You can read more here: http://osdir.com/ml/wine-bugs/2013-07/msg01794.html
Upvotes: 1