How can I open a Word document from my VB application?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Codruta
    New Member
    • May 2011
    • 1

    How can I open a Word document from my VB application?

    I know that exists another topic on this subject and I've read it but for me doesn't work

    Code:
    Dim wrdApp As New Word.Application
            wrdApp.Documents.Open("E:\My Documents\exemplu\exemplu.doc")
            wrdApp.Visible = True
    My error is that word.applicatio n is not defined.

    Can someone help me? I'm using VB2010

    Thanks,
    Codruta
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    You can in VB6 open a program by using the "Shell" command and give the path of the program like this:

    Code:
    Dim Retval
    Retval = Shell("C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE C:\temp\NewDocument.doc", vbMaximizedFocus)

    Comment

    • ToniKati
      New Member
      • Sep 2013
      • 1

      #3
      Hi, are you maybe missing a reference to a Word Interop?
      Code:
      Imports Microsoft.Office.Interop.Word

      Comment

      Working...