Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Problem with Process.Start("WINWORD.EXE", selectedFile); [modified]

Problem with Process.Start("WINWORD.EXE", selectedFile); [modified]

Scheduled Pinned Locked Moved C#
csharphelphtmlvisual-studiodebugging
19 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ _Q12_

    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... :)

    D Offline
    D Offline
    Dave Kreskowiak
    wrote on last edited by
    #9

    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

    _ 1 Reply Last reply
    0
    • D 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 Kreskowiak

      _ Offline
      _ Offline
      _Q12_
      wrote on last edited by
      #10

      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.

      D 1 Reply Last reply
      0
      • _ _Q12_

        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

        _ Offline
        _ Offline
        _Q12_
        wrote on last edited by
        #11

        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.

        G 1 Reply Last reply
        0
        • _ _Q12_

          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... :)

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #12

          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.

          1 Reply Last reply
          0
          • _ _Q12_

            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.

            G Offline
            G Offline
            Ghydo
            wrote on last edited by
            #13

            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?

            _ 1 Reply Last reply
            0
            • G Ghydo

              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?

              _ Offline
              _ Offline
              _Q12_
              wrote on last edited by
              #14

              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.

              L 1 Reply Last reply
              0
              • _ _Q12_

                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.

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #15

                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.

                _ 1 Reply Last reply
                0
                • L Luc Pattyn

                  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.

                  _ Offline
                  _ Offline
                  _Q12_
                  wrote on last edited by
                  #16

                  Yes, it opened the file... and I was not disposed it. Now is working correct. Thank you.

                  1 Reply Last reply
                  0
                  • _ _Q12_

                    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.

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #17

                    There is no way to get Word to stop screwing up your HTML.

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak

                    A 1 Reply Last reply
                    0
                    • D Dave Kreskowiak

                      There is no way to get Word to stop screwing up your HTML.

                      A guide to posting questions on CodeProject[^]
                      Dave Kreskowiak

                      A Offline
                      A Offline
                      AspDotNetDev
                      wrote on last edited by
                      #18

                      Dave Kreskowiak wrote:

                      There is no way to get Work to stop screwing up your HTML.

                      Darn coworkers! ;P

                      [Managing Your JavaScript Library in ASP.NET]

                      D 1 Reply Last reply
                      0
                      • A AspDotNetDev

                        Dave Kreskowiak wrote:

                        There is no way to get Work to stop screwing up your HTML.

                        Darn coworkers! ;P

                        [Managing Your JavaScript Library in ASP.NET]

                        D Offline
                        D Offline
                        Dave Kreskowiak
                        wrote on last edited by
                        #19

                        Damn autocorrect!

                        A guide to posting questions on CodeProject[^]
                        Dave Kreskowiak

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups