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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Joining path and filename ???

Status
Not open for further replies.

borgunit

Programmer
Mar 25, 2002
373
US
Hi,
I thought in the past I had done this but it is not working now. I am trying to join two strings to form a full path to save a file.

i.e.
strFullPath = strPath & strFile

The strPath is something like "M:\Folder\Subfolder\"
The strFile is "001.txt"

When I view them in the watch window, I get a string:
"M:\Folder\Subfolder\ ????"

Have I changed something in my project properties? Both variables are strings and are correct up until the time I put them together.

Perplexed.[surprise]
 
Shouldn't have any problwm with that at all
Can you post the code you are using to assign the variables and the code to join them ??

Rgds
Geoff
"Some cause happiness wherever they go; others whenever they go."
-Oscar Wilde
 
Hi,

There's no "\" at the end of Path

So....
Code:
With ActiveWorkbook
   MyFileName = .Path & "\" & .Name
End With
[\code]
Hope this helps  :-)

Skip,
Skip@TheOfficeExperts.com
[URL unfurl="true"]www.TheOfficeExperts.com[/URL]
 
Skip - Good spot but that'd depend on whether the path is getting picked up from the activeworkbook or being assigned another way - hence why I asked for the code that is being used

Rgds
Geoff
"Some cause happiness wherever they go; others whenever they go."
-Oscar Wilde
 
Hey thanks for the replies. Actually, I build the path as a string depending on some other factors. As a test, I took the path var and cut off the end backslash. I readded it to build the string and now it works. Why is that? Is there a internal rule to not concatenate a string with an ending backslash?
 
Again - can you post the code as it was - we may be able to give you some insight...

Rgds
Geoff
"Some cause happiness wherever they go; others whenever they go."
-Oscar Wilde
 
Here are the offending lines...

strFilePath = GetPath(strTemp)
strName = GetName(strTemp1)
strFileName = strFilePath & strName & ".txt"

-strTemp is a string code i.e. "7ZE-1222-34521"
-GetPath is basically a Select Case function that returns a string path based on the string input. Returns i.e. "M:\Folder\Subfolder\"
-strName is a string that sets the file name i.e. "001" or "002" (it is derived like GetPath)
-strFileName is the concatenation of those (on examination in the watch window it returned "M:\Folder\Subfolder\ ?????")

Any ideas? It does not make sense to me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top