Results 1 to 5 of 5

Thread: [resolved]How do I open an HTML document in Word.

  1. #1

    Thread Starter
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464

    [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.

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    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.

  3. #3

    Thread Starter
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    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.

  4. #4
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    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

  5. #5

    Thread Starter
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    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
  •  



Click Here to Expand Forum to Full Width