Is it possible to send a user an address to a file using either a UNC name or drive path and have that user be able to click on that path like a hyperlink and bring the file up? Example:
\\servernmame\volume\file.filexetension
Printable View
Is it possible to send a user an address to a file using either a UNC name or drive path and have that user be able to click on that path like a hyperlink and bring the file up? Example:
\\servernmame\volume\file.filexetension
I'm not sure, but I think you can. Is this for a web app? If it is, can't you use vbScript to specify that it is a hyperlink? I know how to do it in HTML, not in VB, though:
I hope this helps, though. Good Luck.Code:<a href="path/name/here">Path name here</a>
This app is not for the web I want to send a link to a file for the proper person but attach the file. I thought that if I could send a link that they just could click on and open the file it would be more convenient for them. Any other suggestions?
I think that I got it, you can use the shell command to open it. Example:
Shell ("explorer " & "\\csd044\user\hartlbb\test.pdf"), vbNormalFocus
This will open explorer and then open acrobat and the file.
'Using Shelldef is more appropriate as you don't have
'to hardcode the path to the applications that will open
'the file associated with your filepath/file
Code:'
'This goes in a bas module
'
Option Explicit
'
Public Declare Function ShellEx Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As Any, _
ByVal lpDirectory As Any, ByVal nShowCmd As Long) As Long
'
Public Sub ShellDef(strFileName)
Dim x
x = ShellEx(Form1.hwnd, "open", strFileName, "", "", 1)
End Sub
'Form Event Code
'this goes in your form
'if your path or name is wrong this does not produce
'an error
Private Sub Command1_Click()
Dim strYourFileVariable As String
strYourFileVariable = "c:\my documents\myFile.txt"
ShellDef strYourFileVariable
'=====================================
End Sub
You could always try something like this (I like it a little better than the Shell command)...
Place the following code in the declarations section of a module...
... and place the following code in a form...Code:Public 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
Public Const SW_MAXIMIZE = 3
Public Const SW_MINIMIZE = 6
Public Const SW_RESTORE = 9
Code:Private Sub Command1_Click()
Dim retval As Long
' This will automatically open the document in it's associated application:
retval = ShellExecute(Form1.hWnd, "open", "\\csd044\user\hartlbb\test.pdf", "", _
"\\csd044\user\hartlbb\", SW_RESTORE)
End Sub