Reputation: 156
I have been programming Add-In for Word. I loaded the document into memory as a byte[]
. I need to open it in Word.
Upvotes: 1
Views: 868
Reputation: 12235
It is not possible. Word can not open documents from memory streams. You have to use (temporary) file.
Upvotes: 1
Reputation: 2610
If you have a file stored on HDD and want to open it in MS Word then why are you lading it into memory. You can directly open it using Process Class
Process wordDoc = new Process();
wordDoc.FileName = @"c:\example.docx";
wordDoc.Start();
Upvotes: 0
Reputation: 2518
using System.IO;
public void MyWordFileReaderMethod()
{
string filePath = @"c:\example.docx";
var file = File.ReadAllBytes(filePath);
}
the object file
would contain what you require.
EDIT 1
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "WINWORD.EXE";
startInfo.Arguments = @"c:\tempfile.docx";
Process.Start(startInfo);
If you need to start the memory file with word there is no way but to put it into a temp file and use the code above. 2 processes cannot share data across process boundaries if i am not mistaken.
Upvotes: 1