OPENING A FILE USING A CELL REF.
OPENING A FILE USING A CELL REF.
(OP)
I THINK THIS IS POSSIBLE BUT IM NOT SURE HOW TO DO IT,
I want to open a file, based of a value put in a cell A1.
Say for instance i type in a part number, i want to call up that work instruction file from a directory. Now i think a Hyperlink should play some part in it, but not really sure.
i
I want to open a file, based of a value put in a cell A1.
Say for instance i type in a part number, i want to call up that work instruction file from a directory. Now i think a Hyperlink should play some part in it, but not really sure.
i
RE: OPENING A FILE USING A CELL REF.
Sub OpenSelectedFile()
Dim sFile As String
sFile = "I:\tjc\" & Range("A1") & ".xls"
If Dir(sFile) <> "" Then
Workbooks.Open sFile
Else
MsgBox "Can Not Find File:" & vbCrLf & sFile
End If
End Sub
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
RE: OPENING A FILE USING A CELL REF.
But this code has great application for other things im trying to do. Once again thanks alot.
RE: OPENING A FILE USING A CELL REF.
Sub OpenSelectedFile()
Dim sFile As String
sFile = "I:\tjc\" & Range("A1") & ".doc"
If Dir(sFile) <> "" Then
Call Shell(sFile, vbNormalFocus)
Else
MsgBox "Can Not Find File:" & vbCrLf & sFile
End If
End Sub
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
RE: OPENING A FILE USING A CELL REF.
Call Shell(sFile, vbNormalFocus)
it comes up with file not found, now the file is there, and the file path in line 3 is correct. any ideas?
RE: OPENING A FILE USING A CELL REF.
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
Sub OpenSelectedFile()
Dim sFile As String
sFile = "I:\tjc\" & Range("A1") & ".doc"
If Dir(sFile) <> "" Then
Call ShellExecute(0&, vbNullString, sFile, vbNullString, vbNullString, 5)
Else
MsgBox "Can Not Find File:" & vbCrLf & sFile
End If
End Sub
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
RE: OPENING A FILE USING A CELL REF.