Problem with Process.Start("WINWORD.EXE", selectedFile); [modified]
-
Yes I know, that putting only the fileName+path, that file is opening with the default app. But what I really want is to open a html file and edit it with msword. If you have other alternative than:
Process.Start(myDocFilePath);
please tell. Though, thank you for your fast response... :)Editing an HTML file with Word is a horrible idea. When saved, the resulting HTML file will be all but useless to a website as Word adds TONS of crap to the file that just hoses up everything. CP gets a fair number of articles posted that were written in Word and saved in HTML format. You should see the carnage that ensues.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Editing an HTML file with Word is a horrible idea. When saved, the resulting HTML file will be all but useless to a website as Word adds TONS of crap to the file that just hoses up everything. CP gets a fair number of articles posted that were written in Word and saved in HTML format. You should see the carnage that ensues.
A guide to posting questions on CodeProject[^]
Dave Kreskowiakyes :)) I know that too "Word adds TONS of crap to the resulting HTML". But i dont make it for publication, just for my inner use. So, Ill adapt to its creepiness. If are some hints to make something look good/and right editing with msword, please do tell. thanks.
-
Problem with Process.Start("WINWORD.EXE", selectedFile); I even put the entire path there: //string MSWordPath = @"c:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE"; Still same result: the path and file name is: c:\Users\xxx\Documents\Visual Studio 2010\Projects\zMAP\bridgeWord-Html\bridgeWord-Html\bin\Debug\01 SettingsForVSC#.docx The MSWord is lunched but these errors are thrown: Microsoft Word This file could not be found! (c:\Users\xxx\Documents\Visual.doc) (c:\Users\xxx\Documents\...\Studio.doc) (c:\Users\xxx\Documents\...\01.doc) (c:\Users\xxx\Documents\...\Studio.doc) (c:\Users\xxx\Documents\...\SettingsForVSC#.doc) And then an empty msword page is open. [I see it breaks at the spaces in between names] ---How to fix this problem? I wish to open not only a docx file, but a html file also,or a txt file. thank you.
string path = Application.StartupPath;
private void button3_Click(object sender, EventArgs e)
{
string MSWordPath = "\"c:\\Program Files (x86)\\Microsoft Office\\Office14\\WINWORD.EXE\"";
selectedFile = path + "\\" + listBox1.SelectedItem as string;
//Process.Start("WINWORD.EXE", selectedFile); -or this but the same problem
Process.Start(MSWordPath, selectedFile);
}modified on Friday, May 20, 2011 1:13 PM
-
Yes I know, that putting only the fileName+path, that file is opening with the default app. But what I really want is to open a html file and edit it with msword. If you have other alternative than:
Process.Start(myDocFilePath);
please tell. Though, thank you for your fast response... :)If you want to go against the established file associations, then you need to specify the executable as the first parameter to Process.Start, the arguments concatenated and properly quoted as the second parameter. You already have that. Using Word for HTML editing is a horrible idea. Type three words and you get a huge file, that should tell enough. Use a real HTML editor, or use Visual Studio, or whatever you choose, but not Word. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
I see a little problem with saving from msWord back to original. The file is opened all right, but in read-only. How do I change this? Sorry for my lack of knowledge... but this things are a bit new to me.
-
Do the user under which is running your program have write privileges over the file? Can you open it by hand (eg. open Word and then open the html file) and save it?
-
Yes, If I open it by hand, it is saving ok, loading ok... I am the only user and I have all the privileges over the file R&W.
Does your app (that contains the Process.Start stuff) do something else with the same .doc path, something Stream-like, File-like, FileInfo-like? If so, did you Close() and Dispose() it properly before calling Process.Start()? :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
Does your app (that contains the Process.Start stuff) do something else with the same .doc path, something Stream-like, File-like, FileInfo-like? If so, did you Close() and Dispose() it properly before calling Process.Start()? :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
yes :)) I know that too "Word adds TONS of crap to the resulting HTML". But i dont make it for publication, just for my inner use. So, Ill adapt to its creepiness. If are some hints to make something look good/and right editing with msword, please do tell. thanks.
There is no way to get Word to stop screwing up your HTML.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
There is no way to get Word to stop screwing up your HTML.
A guide to posting questions on CodeProject[^]
Dave KreskowiakDave Kreskowiak wrote:
There is no way to get Work to stop screwing up your HTML.
Darn coworkers! ;P
-
Dave Kreskowiak wrote:
There is no way to get Work to stop screwing up your HTML.
Darn coworkers! ;P
Damn autocorrect!
A guide to posting questions on CodeProject[^]
Dave Kreskowiak