|
-
Oct 23rd, 2003, 11:22 AM
#1
Thread Starter
PowerPoster
[resolved]How do I open an HTML document in Word.
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?
Last edited by hellswraith; Oct 23rd, 2003 at 11:39 AM.
-
Oct 23rd, 2003, 11:30 AM
#2
PowerPoster
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.
-
Oct 23rd, 2003, 11:38 AM
#3
Thread Starter
PowerPoster
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.
-
Oct 23rd, 2003, 12:04 PM
#4
Frenzied Member
this works in C#
Code:
Process.Start("Winword.exe", "C:\\test.html");
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Oct 23rd, 2003, 01:14 PM
#5
Thread Starter
PowerPoster
Originally posted by Memnoch1207
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.
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.
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
|