I used the Common Dialog API to store file paths on my form's underlying table. These paths are displayed in a textbox that I can click to open the selected file.
Having stored the file paths in a textbox on my form, I then changed VB code in a linked module from lpstrFile to lpstrFileTitle (in Line 50 below) to get the file's title instead of the full path. Now, I'd like the file title to keep showing up in the textbox, but I obviously need the full path "underneath " so that, when I click on the file title, the file opens. I've experimented by changing different "lpstrFile" references but can't get the desired result. Here's the On Click event code:
[CODE=vb]Private Sub FilePath_Click( )
Rem Me![AutoNumber]
Dim stlink As String
stlink = Me![FilePath]
FollowHyperlink stlink, , True
End Sub[/CODE]
Here's the related function:
[CODE=vb]Private Declare Function GetOpenFileName Lib "comdlg32.d ll" Alias _
"GetOpenFileNam eA" (pOpenfilename As OPENFILENAME) As Long
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilt er As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Function LaunchCD(strfor m As Form) As String
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
OpenFile.lStruc tSize = Len(OpenFile)
OpenFile.hwndOw ner = strform.Hwnd
sFilter = "All Files (*.*)" & Chr(0) & "*.*" & Chr(0) & _
"HTM Files (*.HTM)" & Chr(0) & "*.HTM" & Chr(0) & _
"HTML Files (*.HTML)" & Chr(0) & "*.HTML" & Chr(0)
OpenFile.lpstrF ilter = sFilter
OpenFile.nFilte rIndex = 2
OpenFile.lpstrF ile = String(257, 0)
OpenFile.nMaxFi le = Len(OpenFile.lp strFile) - 1
OpenFile.lpstrF ileTitle = OpenFile.lpstrF ile
OpenFile.nMaxFi leTitle = OpenFile.nMaxFi le
OpenFile.lpstrI nitialDir = "H:\Application \Cables\"
OpenFile.lpstrT itle = "Select a file..."
OpenFile.flags = 0
lReturn = GetOpenFileName (OpenFile)
If lReturn = 0 Then
MsgBox "No file selected", vbInformation, _
"Please select a file"
Else
LaunchCD = Trim(Left(OpenF ile.lpstrFileTi tle, InStr(1, OpenFile.lpstrF ileTitle, vbNullChar) - 1))
End If
End Function[/CODE]
Can someone clue me in on how to display the FileTitle but link using the path?
Regards,
BASSPU03
Having stored the file paths in a textbox on my form, I then changed VB code in a linked module from lpstrFile to lpstrFileTitle (in Line 50 below) to get the file's title instead of the full path. Now, I'd like the file title to keep showing up in the textbox, but I obviously need the full path "underneath " so that, when I click on the file title, the file opens. I've experimented by changing different "lpstrFile" references but can't get the desired result. Here's the On Click event code:
[CODE=vb]Private Sub FilePath_Click( )
Rem Me![AutoNumber]
Dim stlink As String
stlink = Me![FilePath]
FollowHyperlink stlink, , True
End Sub[/CODE]
Here's the related function:
[CODE=vb]Private Declare Function GetOpenFileName Lib "comdlg32.d ll" Alias _
"GetOpenFileNam eA" (pOpenfilename As OPENFILENAME) As Long
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilt er As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Function LaunchCD(strfor m As Form) As String
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
OpenFile.lStruc tSize = Len(OpenFile)
OpenFile.hwndOw ner = strform.Hwnd
sFilter = "All Files (*.*)" & Chr(0) & "*.*" & Chr(0) & _
"HTM Files (*.HTM)" & Chr(0) & "*.HTM" & Chr(0) & _
"HTML Files (*.HTML)" & Chr(0) & "*.HTML" & Chr(0)
OpenFile.lpstrF ilter = sFilter
OpenFile.nFilte rIndex = 2
OpenFile.lpstrF ile = String(257, 0)
OpenFile.nMaxFi le = Len(OpenFile.lp strFile) - 1
OpenFile.lpstrF ileTitle = OpenFile.lpstrF ile
OpenFile.nMaxFi leTitle = OpenFile.nMaxFi le
OpenFile.lpstrI nitialDir = "H:\Application \Cables\"
OpenFile.lpstrT itle = "Select a file..."
OpenFile.flags = 0
lReturn = GetOpenFileName (OpenFile)
If lReturn = 0 Then
MsgBox "No file selected", vbInformation, _
"Please select a file"
Else
LaunchCD = Trim(Left(OpenF ile.lpstrFileTi tle, InStr(1, OpenFile.lpstrF ileTitle, vbNullChar) - 1))
End If
End Function[/CODE]
Can someone clue me in on how to display the FileTitle but link using the path?
Regards,
BASSPU03
Comment