Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Path is not set completely

  Asked By: Gail    Date: Dec 10    Category: MS Office    Views: 667
  

Can any one please tell me how to i fix that line so that it will get the
whole path as right now in strreturn it pass only upto:\\usnymel1fs001\new
claims\IDT Carmel
instead of the whole path

Public Function StripPath(strFullPath As String) As String
Dim intLoc As Integer
Dim strreturn As String
strFullPath = "\\usnymel1fs001\new claims\IDT Carmel\upload"
intLoc = InStrRev(strFullPath, "\")
If intLoc > 0 Then
strreturn = Left(strFullPath, intLoc - 1)
Debug.Print strreturn
Else
strreturn = "Bad File Path"
End If
StripPath = strreturn
End Function

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Frank Butler     Answered On: Dec 10

I can't understand what you are trying to do. Could you explain a bit.

 
Answer #2    Answered By: Francis Riley     Answered On: Dec 10

1) Before you define this as a function, temporarily modify it to a sub,
so you can check code execution.

2) I strongly recommend you use InStrRev with all optional stuff filled
in, especially the vbvompare bit. So that line  should become

intLoc = InStrRev(strFullPath,"\",1,1) ' Start from position 1, and
compare for text.

Now, change the debug.print line to the following:

Debug.Print intLoc, " || ", strreturn

It should lead you to the answer. And if you can't wait, read on.
------------------------------------------------------------------------
----------------------------------------
You are looking in the full path, from the right, to where the first "\"
is. Now that you have that position, you are asking for all the stuff to
the LEFT of it, excluding the "\" as well.

I think you are getting the answer you have programmed the code to give.
If you want the full path, then that is available as strFullPath...

 
Answer #3    Answered By: Alan Palmer     Answered On: Dec 10

The sub should work, but in this case the argument looks like a
folderpath. If you pass  a full file  name as the argument, the
result should be the folder path...

 
Didn't find what you were looking for? Find more on Path is not set completely Or get search suggestion and latest updates.




Tagged: