visual basic .net shell command with word


i have written a piece of code that when a button is clicked it opens up microsoft word:

        Dim retval
        Dim Hideshow As String
        Hideshow = "Hiding and Showing forms.txt"
        retval = Shell("C:\program files\Microsoft Office\OFFICE11\winword.exe " & Hideshow)

but im not sure if everyones microsoft word .exe will be in the same place, is there anyway to get round this probelm so that everyone will be able to open it with word?


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
if you're trying to open a .doc file, in .NET (VB.NET), you can try like:

'Start Document
    Public Function startDoc(ByVal filepath As String, Optional ByVal args As String = "") As Boolean
            System.Diagnostics.Process.Start(filepath, args)
            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

call like:



startDoc("C:\program files\Microsoft Office\OFFICE11\winword.exe", Hideshow)

else you will need to use the Word Automation Objects instead.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Éric MoreauSenior .Net ConsultantCommented:
don't give the full path (just winword.exe). it will be found.
Éric MoreauSenior .Net ConsultantCommented:
The comment of ryancys applies only to VB.Net.

My suggestion: points to emoreau
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Éric MoreauSenior .Net ConsultantCommented:
ryancys comment is for VB.Net only. The code posted by the asker is VB6. It is defintely not solving the problem!
Ryan ChongCommented:
I can post a VB6 solution that launch word document regardless of where the M$ Word was installed, but it's not meaningful since asker is not responding to this question.

My suggestion: give points to emoreau as he's posted the comment that more suitable for the above question.

Éric MoreauSenior .Net ConsultantCommented:
PAQ_Man, is it worth adding comments on recommended disposition?
Ryan ChongCommented:
oh.. just saw the question title itself did mentioned visual basic .net.... so ?? should we split the points instead, or ......

i'm ok with final decision, cheers
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.