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?
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.
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
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
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?:confused: ?:confused: ?:confused:
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.