Results 1 to 5 of 5

Thread: Run-Time error '76' Path not found

  1. #1

    Thread Starter
    Member MSWindowsUser's Avatar
    Join Date
    Dec 2007
    Posts
    40

    Question Run-Time error '76' Path not found

    Hello, I'm trying to open the Microsoft Word Application and i get that error that's in the title

    Code:
    Private Sub Form_Load()
        Open "D:\Pogram Files\Microsoft Office\OFFICE11\WINWORD.EXE" For Output As #2 (Error on this line)
    End Sub
    Can anyone please help me on this?

    Plus, is there anyway to open the direct path or Program without using the Start > All Programs by using Visual Basic?

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Run-Time error '76' Path not found

    Try Shell ,

    Shell Function Example
    This example uses the Shell function to run an application specified by the user.

    ' Specifying 1 as the second argument opens the application in normal size and gives it the focus.
    Dim RetVal
    RetVal = Shell("C:\WINDOWS\CALC.EXE", 1) ' Run Calculator.

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Run-Time error '76' Path not found

    Automation is best way however Microsoft Word must be installed.
    This will create an instance of MS Word that currently installed on the user's machine:
    Code:
    Private Sub Command1_Click()
    Dim obj As Object
    
        Set obj = CreateObject("Word.Application")
        obj.documents.Add
        obj.Visible = True
        Set obj = Nothing
    
    End Sub

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Run-Time error '76' Path not found

    ShellExecute could also be "best way".
    Code:
    Option Explicit
    
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
        (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
        ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    
    Private Sub Command1_Click()
    Dim myfile As String
    
        'create dummy file with DOC extension
        myfile = "c:\test.doc"
        Open myfile For Output As #1
        Close #1
        
        'open it in default program
        ShellExecute Me.hwnd, vbNullString, myfile, vbNullString, "C:\", vbMaximized
    
    End Sub

  5. #5
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: Run-Time error '76' Path not found

    Quote Originally Posted by MSWindowsUser
    Hello, I'm trying to open the Microsoft Word Application and i get that error that's in the title
    Code:
    Private Sub Form_Load()
        Open "D:\Pogram Files\Microsoft Office\OFFICE11\WINWORD.EXE" For Output As #2 (Error on this line)
    End Sub
    What? ? ?
    You want to open WINWORD.EXE for Output?
    You are lucky when you get an error on that line.
    That command if works will create a new blank file WINWORD.EXE in folder
    D:\Pogram Files\Microsoft Office\OFFICE11\
    If there exist a file WINWORD.EXE there, it will be wiped off and replaced with a blank file.
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width