Question : using variables

Hi EE

I have a function that gives me the drive letter of a USB removeable drive. I am trying to use a variable to be able to create a folder on the removable drive. se code below

Dim xFSO As Object
Dim strDriveName As String
Dim strDriveLetter As String
Dim Path
Dim Tdrive, Tletter
Set xFSO = CreateObject("Scripting.FileSystemObject")



'----------------------------------------- This is not working

Call sListAllDrives
Tdrive = Tremoveable
Path = Tdrive & ":\RnRGear"
'----------------- Check if folder exist
If Not xFSO.FolderExists(Path) Then
        MkDir Tdrive & ":\RnRGear"
End If



'------------------------ This works
Set xFSO = CreateObject("Scripting.FileSystemObject")

Path = "F:\RnRGear"
'----------------- Check if folder exist
If Not xFSO.FolderExists(Path) Then
        MkDir "F:\RnRGear"
End If

If I use "F:\RnRGear" all works ok but if I use  Tdrive & ":\RnRGear" it gives path not found although when I look in the Path = Tdrive & "RnRGear" it appears as "F:\RnRGear"
Any help appreciated

chesters

Answer : using variables

Please change your code as shown, then "run" it. The Immediate window should contain several lines of text after this that show the values of your variables. Please post those lines back here.

Call sListAllDrives
Debug.Print "Tremoveable = " & Tremoveable
Tdrive = Tremoveable
Debug.Print "Tdrive = " & Tdrive
sPath = Tdrive & ":\RnRGear"
Debug.Print "sPath = " & sPath

Random Solutions  
 
programming4us programming4us