Hello,
I need to open a .htm file that is saved on the local machine in Word. How do I do this?
I tried
Process.Start("Winword.exe", "C:\myhtmdoc.htm")
but I get a Document Name or Path invalid error from Word.
Is there a way around this via code?
Printable View
Hello,
I need to open a .htm file that is saved on the local machine in Word. How do I do this?
I tried
Process.Start("Winword.exe", "C:\myhtmdoc.htm")
but I get a Document Name or Path invalid error from Word.
Is there a way around this via code?
Your getting that error because WinWord.exe is not located in your windows directory, so it can't resolve the path. (Just taking a guess here...)
You could store the path to WinWord.exe in your config file and pull it from there at runtime.
I just figured it out. Since my argument is a file path, and that path includes spaces, word is thinking I have many arguments I am passing it. If I put quotes around the path, it works in the Run dialog.
Thanks though.
this works in C#
Code:Process.Start("Winword.exe", "C:\\test.html");
Your right, it does. The problem I was having was there was a space in the string.Quote:
Originally posted by Memnoch1207
this works in C#
Code:Process.Start("Winword.exe", "C:\\test.html");
It looked like this:
Process.Start("Winword.exe", "C:\some folder\test.html")
which in the Run dialog would look like this:
Winword.exe C:\some folder\test.html
And then since there is a space inbetween some and folder, they are seen as two seperate arguments for winword. All I had to do was enclose the path in quotes, and it works just fine.