Opening a document

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

How can I make vb.net open a document in its respective app; word, excel
etc. from a documents name and path? e.g. c:\...\mydoc.doc should
automatically open in word.

Thanks

Regards
 
* "John said:
How can I make vb.net open a document in its respective app; word, excel
etc. from a documents name and path? e.g. c:\...\mydoc.doc should
automatically open in word.

\\\
Dim p As New System.Diagnostics.ProcessStartInfo()
p.Verb = "print"
p.WindowStyle = ProcessWindowStyle.Hidden
p.FileName = "C:\filename.doc"
p.UseShellExecute = True
System.Diagnostics.Process.Start(p)
///
 
Thanks. Do I need to do any cleanup afterwards too, like close the process
etc.?

Regards
 
OK, it works fine for doc, html etc. But I am having problem with pdf and
mpg. I am using blank verb and providing full filename with extension.

p.WindowStyle = ProcessWindowStyle.Hidden
p.FileName = "C:\MyPDF.pdf"

In case of pdf I get the adobe acrobat splash but no document appears once
acrobat is loaded. In mpg, windows player does not appear but the audio
starts to play. If I run the code again them the application (acrobat or
windows player) appears.

What am I missing?

Thanks

Regards
 
* "John said:
OK, it works fine for doc, html etc. But I am having problem with pdf and
mpg. I am using blank verb and providing full filename with extension.

p.WindowStyle = ProcessWindowStyle.Hidden
p.FileName = "C:\MyPDF.pdf"

In case of pdf I get the adobe acrobat splash but no document appears once
acrobat is loaded. In mpg, windows player does not appear but the audio
starts to play. If I run the code again them the application (acrobat or
windows player) appears.

Do you want the application to appear?
 
I just like it to work like when a file is double clicked in windows
explorer. Most of the time the application appears. It is important for
acrobat to appear to read the document. Also windows player is needed when
mpg is a video.

Regards
 
* "John said:
I just like it to work like when a file is double clicked in windows
explorer. Most of the time the application appears. It is important for
acrobat to appear to read the document. Also windows player is needed when
mpg is a video.

Why do you set 'WindowStyle' to 'Hidden'?
 
Sorry, it was in your original code and I left it like that., So, is that I
need to change?

Regards
 
* "John said:
Sorry, it was in your original code and I left it like that., So, is that I
need to change?

Yes, remove the line. I feel sorry for not removing it in the original
post.
 
Back
Top