473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Process to open a document

I have created a mail merged document at run time.
However, I cannot open the document everytime, sometime it did not get
opened, sometimes it can.
The document may be Word or text file.

public static void OpenDocument(string aFilename)

{

IntPtr result;

Process convertProcess = new Process();

try

{

convertProcess.StartInfo.Domain = "";

convertProcess.StartInfo.FileName = aFilename;

convertProcess.StartInfo.CreateNoWindow = true;

convertProcess.StartInfo.WindowStyle =
System.Diagnostics.ProcessWindowStyle.Maximized;

convertProcess.StartInfo.StandardErrorEncoding = null;

convertProcess.StartInfo.StandardOutputEncoding = null;

convertProcess.StartInfo.UseShellExecute = true;

convertProcess.StartInfo.LoadUserProfile = false;

convertProcess.StartInfo.Password = null;

convertProcess.StartInfo.UserName = "";

convertProcess.Start();

convertProcess.Dispose();

}

catch (Exception e)

{

try

{

convertProcess.Dispose();

}

catch

{

}

}
}
Dec 6 '06 #1
5 1904
Text file? Text file sure cannot run macro. You are using VSTO or just VBA?

chanmm

"Alan T" <al*************@yahoo.com.auwrote in message
news:u1**************@TK2MSFTNGP04.phx.gbl...
>I have created a mail merged document at run time.
However, I cannot open the document everytime, sometime it did not get
opened, sometimes it can.
The document may be Word or text file.

public static void OpenDocument(string aFilename)

{

IntPtr result;

Process convertProcess = new Process();

try

{

convertProcess.StartInfo.Domain = "";

convertProcess.StartInfo.FileName = aFilename;

convertProcess.StartInfo.CreateNoWindow = true;

convertProcess.StartInfo.WindowStyle =
System.Diagnostics.ProcessWindowStyle.Maximized;

convertProcess.StartInfo.StandardErrorEncoding = null;

convertProcess.StartInfo.StandardOutputEncoding = null;

convertProcess.StartInfo.UseShellExecute = true;

convertProcess.StartInfo.LoadUserProfile = false;

convertProcess.StartInfo.Password = null;

convertProcess.StartInfo.UserName = "";

convertProcess.Start();

convertProcess.Dispose();

}

catch (Exception e)

{

try

{

convertProcess.Dispose();

}

catch

{

}

}
}

Dec 6 '06 #2
Hi,

The method I stated was written by C#, the parameter aFilename is the full
path file name.

"Chan Ming Man" <ch*****@hotmail.comwrote in message
news:F9**********************************@microsof t.com...
Text file? Text file sure cannot run macro. You are using VSTO or just
VBA?

chanmm

"Alan T" <al*************@yahoo.com.auwrote in message
news:u1**************@TK2MSFTNGP04.phx.gbl...
>>I have created a mail merged document at run time.
However, I cannot open the document everytime, sometime it did not get
opened, sometimes it can.
The document may be Word or text file.

public static void OpenDocument(string aFilename)

{

IntPtr result;

Process convertProcess = new Process();

try

{

convertProcess.StartInfo.Domain = "";

convertProcess.StartInfo.FileName = aFilename;

convertProcess.StartInfo.CreateNoWindow = true;

convertProcess.StartInfo.WindowStyle =
System.Diagnostics.ProcessWindowStyle.Maximized ;

convertProcess.StartInfo.StandardErrorEncoding = null;

convertProcess.StartInfo.StandardOutputEncoding = null;

convertProcess.StartInfo.UseShellExecute = true;

convertProcess.StartInfo.LoadUserProfile = false;

convertProcess.StartInfo.Password = null;

convertProcess.StartInfo.UserName = "";

convertProcess.Start();

convertProcess.Dispose();

}

catch (Exception e)

{

try

{

convertProcess.Dispose();

}

catch

{

}

}
}


Dec 6 '06 #3
Did you check the process? Can it be the program is running but the Word is
not appearing?

chanmm

"Alan T" <al*************@yahoo.com.auwrote in message
news:OA**************@TK2MSFTNGP04.phx.gbl...
Hi,

The method I stated was written by C#, the parameter aFilename is the full
path file name.

"Chan Ming Man" <ch*****@hotmail.comwrote in message
news:F9**********************************@microsof t.com...
>Text file? Text file sure cannot run macro. You are using VSTO or just
VBA?

chanmm

"Alan T" <al*************@yahoo.com.auwrote in message
news:u1**************@TK2MSFTNGP04.phx.gbl...
>>>I have created a mail merged document at run time.
However, I cannot open the document everytime, sometime it did not get
opened, sometimes it can.
The document may be Word or text file.

public static void OpenDocument(string aFilename)

{

IntPtr result;

Process convertProcess = new Process();

try

{

convertProcess.StartInfo.Domain = "";

convertProcess.StartInfo.FileName = aFilename;

convertProcess.StartInfo.CreateNoWindow = true;

convertProcess.StartInfo.WindowStyle =
System.Diagnostics.ProcessWindowStyle.Maximize d;

convertProcess.StartInfo.StandardErrorEncoding = null;

convertProcess.StartInfo.StandardOutputEncoding = null;

convertProcess.StartInfo.UseShellExecute = true;

convertProcess.StartInfo.LoadUserProfile = false;

convertProcess.StartInfo.Password = null;

convertProcess.StartInfo.UserName = "";

convertProcess.Start();

convertProcess.Dispose();

}

catch (Exception e)

{

try

{

convertProcess.Dispose();

}

catch

{

}

}
}


Dec 7 '06 #4
The document did not get opened and also the MS Word did not run.

"Chan Ming Man" <ch*****@hotmail.comwrote in message
news:3B**********************************@microsof t.com...
Did you check the process? Can it be the program is running but the Word
is not appearing?

chanmm

"Alan T" <al*************@yahoo.com.auwrote in message
news:OA**************@TK2MSFTNGP04.phx.gbl...
>Hi,

The method I stated was written by C#, the parameter aFilename is the
full path file name.

"Chan Ming Man" <ch*****@hotmail.comwrote in message
news:F9**********************************@microso ft.com...
>>Text file? Text file sure cannot run macro. You are using VSTO or just
VBA?

chanmm

"Alan T" <al*************@yahoo.com.auwrote in message
news:u1**************@TK2MSFTNGP04.phx.gbl...
I have created a mail merged document at run time.
However, I cannot open the document everytime, sometime it did not get
opened, sometimes it can.
The document may be Word or text file.

public static void OpenDocument(string aFilename)

{

IntPtr result;

Process convertProcess = new Process();

try

{

convertProcess.StartInfo.Domain = "";

convertProcess.StartInfo.FileName = aFilename;

convertProcess.StartInfo.CreateNoWindow = true;

convertProcess.StartInfo.WindowStyle =
System.Diagnostics.ProcessWindowStyle.Maximized ;

convertProcess.StartInfo.StandardErrorEncoding = null;

convertProcess.StartInfo.StandardOutputEncoding = null;

convertProcess.StartInfo.UseShellExecute = true;

convertProcess.StartInfo.LoadUserProfile = false;

convertProcess.StartInfo.Password = null;

convertProcess.StartInfo.UserName = "";

convertProcess.Start();

convertProcess.Dispose();

}

catch (Exception e)

{

try

{

convertProcess.Dispose();

}

catch

{

}

}
}


Dec 7 '06 #5
Why are you calling the Dispose() method immediately after Start()? Can
it be that the process is starting and then closing immediately?
-Samik

On 12/7/2006 4:23 PM, Alan T wrote:
The document did not get opened and also the MS Word did not run.

"Chan Ming Man" <ch*****@hotmail.comwrote in message
news:3B**********************************@microsof t.com...
>Did you check the process? Can it be the program is running but the Word
is not appearing?

chanmm

"Alan T" <al*************@yahoo.com.auwrote in message
news:OA**************@TK2MSFTNGP04.phx.gbl...
>>Hi,

The method I stated was written by C#, the parameter aFilename is the
full path file name.

"Chan Ming Man" <ch*****@hotmail.comwrote in message
news:F9**********************************@micros oft.com...
Text file? Text file sure cannot run macro. You are using VSTO or just
VBA?

chanmm

"Alan T" <al*************@yahoo.com.auwrote in message
news:u1**************@TK2MSFTNGP04.phx.gbl...
I have created a mail merged document at run time.
However, I cannot open the document everytime, sometime it did not get
opened, sometimes it can.
The document may be Word or text file.
>
public static void OpenDocument(string aFilename)
>
{
>
IntPtr result;
>
Process convertProcess = new Process();
>
try
>
{
>
convertProcess.StartInfo.Domain = "";
>
convertProcess.StartInfo.FileName = aFilename;
>
convertProcess.StartInfo.CreateNoWindow = true;
>
convertProcess.StartInfo.WindowStyle =
System.Diagnostics.ProcessWindowStyle.Maximize d;
>
convertProcess.StartInfo.StandardErrorEncoding = null;
>
convertProcess.StartInfo.StandardOutputEncoding = null;
>
convertProcess.StartInfo.UseShellExecute = true;
>
convertProcess.StartInfo.LoadUserProfile = false;
>
convertProcess.StartInfo.Password = null;
>
convertProcess.StartInfo.UserName = "";
>
convertProcess.Start();
>
convertProcess.Dispose();
>
}
>
catch (Exception e)
>
{
>
try
>
{
>
convertProcess.Dispose();
>
}
>
catch
>
{
>
}
>
}
>
>
}
>
>

Jan 11 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Peter Åstrand | last post by:
There's a new PEP available: PEP 324: popen5 - New POSIX process module A copy is included below. Comments are appreciated. ---- PEP: 324 Title: popen5 - New POSIX process module
1
by: Fei Yuan | last post by:
Please forgive me re-posting this question since I wasn't clear in my original post. --------> Starting an external process needs to pass it a ProcessStartInfo() object. ProcessStartInfo has a...
3
by: sandro72 | last post by:
I found the classes you wrote of but it doesn't work. i tested also this code but it cretaes instances of worpad.exe that i only see by task manager and i cannot terminate them. have you any...
2
by: genojoe | last post by:
The command below opens a Word document but to use it I need to know the path for Winword.EXE Process.Start(C:\Office2003\OFFICE11\WINWORD.EXE, C:\Data\Print.rtf") Is there a command that I...
3
by: Dean Slindee | last post by:
The code below is being used to launch WinWord.exe from a VB.NET program. Word launches, but displays this error message: "Word has experienced an error trying to open the file. Try these...
2
by: Dean Slindee | last post by:
The code below is being used to launch WinWord.exe from a VB.NET program. Word launches, but displays this error message: "Word has experienced an error trying to open the file. Try these...
3
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
17
by: asearle | last post by:
Hallo everyone, After playing around with 'fork' in order to try to get a one process to monitor another, I have changed my tack and switched to Win32::Process. Indeed, it looks like this...
7
by: =?Utf-8?B?ams=?= | last post by:
I am using System.Diagnostics.Process class to open a word document by call ing Process.Start("test.doc"). I am using C# as programming language. On some of the computers on running this code i get...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.