Jumat, 10 Mei 2013

Re: [MS_AccessPros] Allowing a user to select a file and insert a hyperlink to the file

 

John F. -
This should do it for you.

Public Function FindFileName(strFullPath As String) As String
Dim intPos As Integer
Dim strTemp As String

intPos = InStrRev(strFullPath, "\")
strTemp = Mid(strFullPath, intPos + 1)
intPos = InStr(1, strTemp, ".")
strTemp = Left(strTemp, intPos - 1)
FindFileName = strTemp


End Function

Bill

--- In MS_Access_Professionals@yahoogroups.com, "jfakes.rm" <jfakes@...> wrote:
>
> Ok, I'm finding out that the hyperlink does open Excel, however, I have to click on the view fullscreen icon then the normal view icon before I can see the spreadsheet. Very strange. I have a ticket open with IT to see if they can figure out why I can't see the spreadsheet as soon as excel opens.
>
> I still need help figuring out how to grab the file name. I know I have to use a combination of trim etc, but I'm not sure of how to format the code.
>
> I would like to strip off everything but the file name and store that in txtDocumentName. For example: the link is: \\server\directory\MyDoc.doc. I want to store MyDoc in txtDocumentName.
>
>
> --- In MS_Access_Professionals@yahoogroups.com, "jfakes.rm" <jfakes@> wrote:
> >
> > John V.,
> > I changed the code adding what you sent. It works with a .doc or .pdf, I can click on the new link and the file opens. However, if I have a spreadsheet (.xls or .xlsx) when I try to open the spreadsheet, when I click on the link to open it, Excel opens and I can see that the selected spreadsheet says it is open, however, I can't see the spreadsheet it displays like a screenshot of the database screen.
> >
> > Any suggestions?
> >
> > Also, once I capture the link, I would like to strip off everything but the file name and store that in txtDocumentName. For example: the link is: \\server\directory\MyDoc.doc. I want to store MyDoc in txtDocumentName.
> >
> > John
> >
> > --- In MS_Access_Professionals@yahoogroups.com, John Viescas <JohnV@> wrote:
> > >
> > > Do this:
> > >
> > > Me.txtFlaggedDocumentLink = "#" & fileName
> > >
> > >
> > > John Viescas, Author
> > > Microsoft Access 2010 Inside Out
> > > Microsoft Access 2007 Inside Out
> > > Microsoft Access 2003 Inside Out
> > > Building Microsoft Access Applications
> > > SQL Queries for Mere Mortals
> > > http://www.viescas.com/
> > > (Paris, France)
> > >
> > >
> > >
> > > -----Original Message-----
> > > From: MS_Access_Professionals@yahoogroups.com
> > > [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of jfakes.rm
> > > Sent: Thursday, May 09, 2013 10:43 PM
> > > To: MS_Access_Professionals@yahoogroups.com
> > > Subject: [MS_AccessPros] Allowing a user to select a file and insert a
> > > hyperlink to the file
> > >
> > > I'm trying to create a command button on a form that allows a user to browse
> > > to a file and once selected, insert the hyperlink to the file.
> > >
> > > The hyperlink address needs to be saved in a field called:
> > > txtFlaggedDocumentLink (which is a hyperlink field).
> > >
> > > I've pieced together the following after searching the web, however, while
> > > the path to the filename is saved correctly, when I click on the link, it
> > > doesn't work. It appears to be a hyperlink, but it won't work.
> > >
> > > Private Sub cmdFindFile_Click()
> > > 'Sub getFileName()
> > > ' Displays the Office File Open dialog to choose a file.
> > > Dim fileName As String
> > > Dim result As Integer
> > > With Application.FileDialog(1) ' 3 is a constant: msoFileDialogFilePicker
> > > .Title = "Select File"
> > > .Filters.Add "All Files", "*.*"
> > > .FilterIndex = 1
> > > .AllowMultiSelect = False
> > > '.InitialFileName = CurrentProject.Path
> > > ' This opens the NCQA library folder to start the search.
> > > .InitialFileName = "\\Rmregfile017\ncqalibrary"
> > > result = .Show
> > > If (result <> 0) Then 'result = 0 if nothing was selected fileName =
> > > Trim(.SelectedItems.Item(1)) 'filename contains the path you want.
> > > Me.txtFlaggedDocumentLink = fileName
> > >
> > > End If
> > > End With
> > >
> > > End Sub
> > >
> > > Any suggestions?
> > >
> > > I also tried,
> > >
> > >
> > >
> > > ------------------------------------
> > >
> > > Yahoo! Groups Links
> > >
> >
>

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (6)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar