Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

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?


  • 4
  • 3
1 Solution
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.
É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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

É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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now