pendragon Posted June 30, 2005 Posted June 30, 2005 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 Quote
IngisKahn Posted June 30, 2005 Posted June 30, 2005 Surround the path in quotes. Quote "Who is John Galt?"
Moderators Robby Posted June 30, 2005 Moderators Posted June 30, 2005 Replace all spaces with %20 Quote Visit...Bassic Software
Moderators Robby Posted June 30, 2005 Moderators Posted June 30, 2005 Ot like Ingis stated; surround the string in quotes. :) Quote Visit...Bassic Software
pendragon Posted July 1, 2005 Author Posted July 1, 2005 Thanks guys that works, such a simple solutions but I just couldn't see it last night. (need more sleep or caffeine :) ) Quote
jmcilhinney Posted July 1, 2005 Posted July 1, 2005 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") Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.