Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String manipulation

Status
Not open for further replies.

nastar1

Technical User
Nov 1, 2005
122
US
My code below had been working but something I must have changed has rendered the code below invalid. I now get the msgbox error "file not found" which comes from error trap code I've included. I may not have this code setup correctly.

My textbox TaskDescrip is populated from another command button that inserts a hyperlink to a source file using the acCmdInsertHyperlink.
The button code below is supposed to take the TaskDescrip value and convert it to an I: drive path and then repopulate the TaskDescrip textbox with the hyperlink equivalent of that I: drive path/filename. I need the cmdSaveHyper to convert only the filename in the textbox regardless whether it has a path included or not. Can anyone see where I am missing the boat on this code?

Private Sub cmdSaveHyper_Click()
On Error GoTo Err_cmdSaveHyper_Click

Dim Ofile As String
Dim DestFile
Dim strFileName As String
Dim strMyHyper As String
Dim TaskHyp, RemvHyp, DestHyp As String

Ofile = Me!TaskDescrip
TaskHyp = TaskDescrip.Value 'TaskDescrip is a hyperlink value at this point

'to get just the filename from the hyperlink path in TaskDescrip
If InStr(TaskDescrip.Value, "\") > 0 Then
strFileName = Right(TaskHyp, Len(TaskHyp) - InStrRev(TaskHyp, "\"))
Else
strFileName = TaskDescrip.Value

End If



RemvHyp = Left(strFileName, Len(strFileName) - 1)

DestFile = "I:\SNL\09 - Contractor General Files\WAMS_Docs\" & RemvHyp

'to get the path
TaskHyp = HyperlinkPart(TaskDescrip, acDisplayedValue)


DestHyp = DestFile
FileCopy TaskHyp, DestHyp

're-embed hyperlink
TaskDescrip = "#" & DestHyp & "#"


Exit_cmdSaveHyper_Click:
Exit Sub

Err_cmdSaveHyper_Click:
MsgBox Err.Description
MsgBox "Make sure file is on the C Drive and try to browse file again", vbInformation, Error

Resume Exit_cmdSaveHyper_Click

End Sub
 
Seems pretty obvious that whatever file path that's in TaskHyp is not valid. Put a stop point on the FileCopy statement and check what TaskHyp's value is.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top