Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi All

 

Hope you can help, I am trying to open word and pass the document to open as a string.

 

If the string is c:\bin\calllog.doc then it opens fine but if the path includes spaces then word says it can't find the document

 

ie c:\Documents and Setting\Administrator\My Documents\CallLog.doc

 

Can some one please tell me what it is I am forgetting to do :confused:

 

this is the code I am using

 

Process MyProcess;

string ProgramToRun = "WINWORD.EXE";
string DocumentToOpen = dataaccess.rowActions[dataaccess.colACTAttachmentPath].ToString() + dataaccess.rowActions[dataaccess.colACTAttachment].ToString();

MessageBox.Show(DocumentToOpen);

MyProcess = Process.Start(ProgramToRun, DocumentToOpen);
MyProcess.WaitForInputIdle();
MyProcess.Close();
MyProcess.Dispose();

 

Thank you for your help

Posted
By the way, you can simply pass the file path to Process.Start for a registered file type to open the file with the default program. It's not a big deal here, but if you had had to provide the full path to WinWord and didn't know it on another machine it would be an issue:
Process.Start("C:\\MyDocument.doc")

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...