|
-
March 20th, 2013, 02:22 PM
#3
Re: Open a Word document in which the file name is user input
Ok, so I took out the FileStream, but now I have another error. I have made a Word AddIn form with the below code. When I go to run it, it populates an error saying the file does not exist...
It's like it does not recognize the user input part of the code. Any idea if I need to use different code to collect the file name from the user?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Word;
using System.IO;
namespace WordAddIn2
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
System.Console.Write("Enter the file name: ");
String fileName = System.Console.ReadLine();
Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application();
Word._Document oDoc;
oDoc = oWord.Documents.Open(@"H:\SNH\" + fileName);
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|