Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Help to Indentify a drive letter

Can anyone help with the code to first identify a drive letter on PC which
may also be different to the one on the PC that the macro was built on. I
need to save a file to a specific folder path and if the drive letter is
different how to specify a folder path.

I hope that makes sense?

--
Kind Regards

Mick


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help to Indentify a drive letter

What information do you have to start with? How would we know we have the
right drive?

Do you want to search all drives for a particular folder?

--
Regards,
Tom Ogilvy


"Grandad" wrote in message
...
Can anyone help with the code to first identify a drive letter on PC which
may also be different to the one on the PC that the macro was built on. I
need to save a file to a specific folder path and if the drive letter is
different how to specify a folder path.

I hope that makes sense?

--
Kind Regards

Mick




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help to Indentify a drive letter

If you have a path string:

Sub findDrive()
Dim fs As Object, f As Object
Dim sPath As String, drv As Object
Dim sPath1 As String
sPath = "Data\CSVDaily"
Set fs = CreateObject("Scripting.FileSystemObject")
For Each drv In fs.Drives
sPath1 = drv.DriveLetter & ":\" & sPath
On Error Resume Next
Set f = Nothing
Set f = fs.GetFolder(sPath1)
On Error GoTo 0
If Not f Is Nothing Then
MsgBox "found in drive " & drv.DriveLetter
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
What information do you have to start with? How would we know we have the
right drive?

Do you want to search all drives for a particular folder?

--
Regards,
Tom Ogilvy


"Grandad" wrote in message
...
Can anyone help with the code to first identify a drive letter on PC

which
may also be different to the one on the PC that the macro was built on.

I
need to save a file to a specific folder path and if the drive letter is
different how to specify a folder path.

I hope that makes sense?

--
Kind Regards

Mick






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Help to Indentify a drive letter

Tom

I'm sorry if I've not been clear.

I guess what I need is to be able to identify the default drive letter for
each PC the macro is used on and to have a folder path to save a file that
works on all PCs.

I hope that's a bit better tan my first attempt?

Mick


"Tom Ogilvy" wrote in message
...
If you have a path string:

Sub findDrive()
Dim fs As Object, f As Object
Dim sPath As String, drv As Object
Dim sPath1 As String
sPath = "Data\CSVDaily"
Set fs = CreateObject("Scripting.FileSystemObject")
For Each drv In fs.Drives
sPath1 = drv.DriveLetter & ":\" & sPath
On Error Resume Next
Set f = Nothing
Set f = fs.GetFolder(sPath1)
On Error GoTo 0
If Not f Is Nothing Then
MsgBox "found in drive " & drv.DriveLetter
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
What information do you have to start with? How would we know we have

the
right drive?

Do you want to search all drives for a particular folder?

--
Regards,
Tom Ogilvy


"Grandad" wrote in message
...
Can anyone help with the code to first identify a drive letter on PC

which
may also be different to the one on the PC that the macro was built

on.
I
need to save a file to a specific folder path and if the drive letter

is
different how to specify a folder path.

I hope that makes sense?

--
Kind Regards

Mick








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help to Indentify a drive letter

Dim sDrive as String
sDrive = left(curdir,1)
on error resume next
mkdir sDrive & ":\MyMacroFolder"
On error goto 0
Application.displayalerts = False
ThisWorkbook.SaveAs sDrive & ":\MyMacroFolder\" & thisworkbook.Name
Application.DisplayAlerts = True

--
Regards,
Tom Ogilvy



"Grandad" wrote in message
...
Tom

I'm sorry if I've not been clear.

I guess what I need is to be able to identify the default drive letter for
each PC the macro is used on and to have a folder path to save a file that
works on all PCs.

I hope that's a bit better tan my first attempt?

Mick


"Tom Ogilvy" wrote in message
...
If you have a path string:

Sub findDrive()
Dim fs As Object, f As Object
Dim sPath As String, drv As Object
Dim sPath1 As String
sPath = "Data\CSVDaily"
Set fs = CreateObject("Scripting.FileSystemObject")
For Each drv In fs.Drives
sPath1 = drv.DriveLetter & ":\" & sPath
On Error Resume Next
Set f = Nothing
Set f = fs.GetFolder(sPath1)
On Error GoTo 0
If Not f Is Nothing Then
MsgBox "found in drive " & drv.DriveLetter
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
What information do you have to start with? How would we know we have

the
right drive?

Do you want to search all drives for a particular folder?

--
Regards,
Tom Ogilvy


"Grandad" wrote in message
...
Can anyone help with the code to first identify a drive letter on PC

which
may also be different to the one on the PC that the macro was built

on.
I
need to save a file to a specific folder path and if the drive

letter
is
different how to specify a folder path.

I hope that makes sense?

--
Kind Regards

Mick












  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Help to Indentify a drive letter

Thanks Tom I'll try that,

I know how to move forward in a folder structure, but how do to go back?

Thanks again Mick

"Tom Ogilvy" wrote in message
...
Dim sDrive as String
sDrive = left(curdir,1)
on error resume next
mkdir sDrive & ":\MyMacroFolder"
On error goto 0
Application.displayalerts = False
ThisWorkbook.SaveAs sDrive & ":\MyMacroFolder\" & thisworkbook.Name
Application.DisplayAlerts = True

--
Regards,
Tom Ogilvy



"Grandad" wrote in message
...
Tom

I'm sorry if I've not been clear.

I guess what I need is to be able to identify the default drive letter

for
each PC the macro is used on and to have a folder path to save a file

that
works on all PCs.

I hope that's a bit better tan my first attempt?

Mick


"Tom Ogilvy" wrote in message
...
If you have a path string:

Sub findDrive()
Dim fs As Object, f As Object
Dim sPath As String, drv As Object
Dim sPath1 As String
sPath = "Data\CSVDaily"
Set fs = CreateObject("Scripting.FileSystemObject")
For Each drv In fs.Drives
sPath1 = drv.DriveLetter & ":\" & sPath
On Error Resume Next
Set f = Nothing
Set f = fs.GetFolder(sPath1)
On Error GoTo 0
If Not f Is Nothing Then
MsgBox "found in drive " & drv.DriveLetter
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
What information do you have to start with? How would we know we

have
the
right drive?

Do you want to search all drives for a particular folder?

--
Regards,
Tom Ogilvy


"Grandad" wrote in message
...
Can anyone help with the code to first identify a drive letter on

PC
which
may also be different to the one on the PC that the macro was

built
on.
I
need to save a file to a specific folder path and if the drive

letter
is
different how to specify a folder path.

I hope that makes sense?

--
Kind Regards

Mick












  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help to Indentify a drive letter

chdir ..

--
Regards,
Tom Ogilvy

"Grandad" wrote in message
...
Thanks Tom I'll try that,

I know how to move forward in a folder structure, but how do to go back?

Thanks again Mick

"Tom Ogilvy" wrote in message
...
Dim sDrive as String
sDrive = left(curdir,1)
on error resume next
mkdir sDrive & ":\MyMacroFolder"
On error goto 0
Application.displayalerts = False
ThisWorkbook.SaveAs sDrive & ":\MyMacroFolder\" & thisworkbook.Name
Application.DisplayAlerts = True

--
Regards,
Tom Ogilvy



"Grandad" wrote in message
...
Tom

I'm sorry if I've not been clear.

I guess what I need is to be able to identify the default drive letter

for
each PC the macro is used on and to have a folder path to save a file

that
works on all PCs.

I hope that's a bit better tan my first attempt?

Mick


"Tom Ogilvy" wrote in message
...
If you have a path string:

Sub findDrive()
Dim fs As Object, f As Object
Dim sPath As String, drv As Object
Dim sPath1 As String
sPath = "Data\CSVDaily"
Set fs = CreateObject("Scripting.FileSystemObject")
For Each drv In fs.Drives
sPath1 = drv.DriveLetter & ":\" & sPath
On Error Resume Next
Set f = Nothing
Set f = fs.GetFolder(sPath1)
On Error GoTo 0
If Not f Is Nothing Then
MsgBox "found in drive " & drv.DriveLetter
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
What information do you have to start with? How would we know we

have
the
right drive?

Do you want to search all drives for a particular folder?

--
Regards,
Tom Ogilvy


"Grandad" wrote in message
...
Can anyone help with the code to first identify a drive letter

on
PC
which
may also be different to the one on the PC that the macro was

built
on.
I
need to save a file to a specific folder path and if the drive

letter
is
different how to specify a folder path.

I hope that makes sense?

--
Kind Regards

Mick














  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Help to Indentify a drive letter

Sorry Tom

I don't know how to use chdir..

I have a line something like:

Thisworkbook.Path is in folder4

ActiveWorkbook.SaveA FileName:=Thisworkbook.Path &
"\folder5\folder6\folder7" &ThisWorkBook.name

How do I go from ThisWorkBook.Path to \folder3 or folder2 etc?

Regards

Mick


"Tom Ogilvy" wrote in message
...
chdir ..

--
Regards,
Tom Ogilvy

"Grandad" wrote in message
...
Thanks Tom I'll try that,

I know how to move forward in a folder structure, but how do to go back?

Thanks again Mick

"Tom Ogilvy" wrote in message
...
Dim sDrive as String
sDrive = left(curdir,1)
on error resume next
mkdir sDrive & ":\MyMacroFolder"
On error goto 0
Application.displayalerts = False
ThisWorkbook.SaveAs sDrive & ":\MyMacroFolder\" & thisworkbook.Name
Application.DisplayAlerts = True

--
Regards,
Tom Ogilvy



"Grandad" wrote in message
...
Tom

I'm sorry if I've not been clear.

I guess what I need is to be able to identify the default drive

letter
for
each PC the macro is used on and to have a folder path to save a

file
that
works on all PCs.

I hope that's a bit better tan my first attempt?

Mick


"Tom Ogilvy" wrote in message
...
If you have a path string:

Sub findDrive()
Dim fs As Object, f As Object
Dim sPath As String, drv As Object
Dim sPath1 As String
sPath = "Data\CSVDaily"
Set fs = CreateObject("Scripting.FileSystemObject")
For Each drv In fs.Drives
sPath1 = drv.DriveLetter & ":\" & sPath
On Error Resume Next
Set f = Nothing
Set f = fs.GetFolder(sPath1)
On Error GoTo 0
If Not f Is Nothing Then
MsgBox "found in drive " & drv.DriveLetter
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
What information do you have to start with? How would we know

we
have
the
right drive?

Do you want to search all drives for a particular folder?

--
Regards,
Tom Ogilvy


"Grandad" wrote in message
...
Can anyone help with the code to first identify a drive letter

on
PC
which
may also be different to the one on the PC that the macro was

built
on.
I
need to save a file to a specific folder path and if the drive
letter
is
different how to specify a folder path.

I hope that makes sense?

--
Kind Regards

Mick
















  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help to Indentify a drive letter

varr = Split(Thisworkbook.path)
for i = lbound(varr) to ubound(varr)
debug.print varr(i)
Next

if you wanted to save the file two directories above its current directory

? thisworkbook.Path
D:\folder1\folder2\folder3\folder4

ActiveWorkbook.SaveAs FileName:=Thisworkbook.Path & _
"\..\..\" & ThisWorkBook.name

? thisworkbook.Path
D:\folder1\folder2

two dots/periods means the directory above.

--
Regards,
Tom Ogilvy

"Grandad" wrote in message
...
Sorry Tom

I don't know how to use chdir..

I have a line something like:

Thisworkbook.Path is in folder4

ActiveWorkbook.SaveA FileName:=Thisworkbook.Path &
"\folder5\folder6\folder7" &ThisWorkBook.name

How do I go from ThisWorkBook.Path to \folder3 or folder2 etc?

Regards

Mick


"Tom Ogilvy" wrote in message
...
chdir ..

--
Regards,
Tom Ogilvy

"Grandad" wrote in message
...
Thanks Tom I'll try that,

I know how to move forward in a folder structure, but how do to go

back?

Thanks again Mick

"Tom Ogilvy" wrote in message
...
Dim sDrive as String
sDrive = left(curdir,1)
on error resume next
mkdir sDrive & ":\MyMacroFolder"
On error goto 0
Application.displayalerts = False
ThisWorkbook.SaveAs sDrive & ":\MyMacroFolder\" & thisworkbook.Name
Application.DisplayAlerts = True

--
Regards,
Tom Ogilvy



"Grandad" wrote in message
...
Tom

I'm sorry if I've not been clear.

I guess what I need is to be able to identify the default drive

letter
for
each PC the macro is used on and to have a folder path to save a

file
that
works on all PCs.

I hope that's a bit better tan my first attempt?

Mick


"Tom Ogilvy" wrote in message
...
If you have a path string:

Sub findDrive()
Dim fs As Object, f As Object
Dim sPath As String, drv As Object
Dim sPath1 As String
sPath = "Data\CSVDaily"
Set fs = CreateObject("Scripting.FileSystemObject")
For Each drv In fs.Drives
sPath1 = drv.DriveLetter & ":\" & sPath
On Error Resume Next
Set f = Nothing
Set f = fs.GetFolder(sPath1)
On Error GoTo 0
If Not f Is Nothing Then
MsgBox "found in drive " & drv.DriveLetter
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
What information do you have to start with? How would we know

we
have
the
right drive?

Do you want to search all drives for a particular folder?

--
Regards,
Tom Ogilvy


"Grandad" wrote in message
...
Can anyone help with the code to first identify a drive

letter
on
PC
which
may also be different to the one on the PC that the macro

was
built
on.
I
need to save a file to a specific folder path and if the

drive
letter
is
different how to specify a folder path.

I hope that makes sense?

--
Kind Regards

Mick


















  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Help to Indentify a drive letter

Tom it's working more or less as I need it too so thanks for your help.

Having created the new folder is there a way to go back or identify the
original drive we started from?

Regards

Mick

"Tom Ogilvy" wrote in message
...
Dim sDrive as String
sDrive = left(curdir,1)
on error resume next
mkdir sDrive & ":\MyMacroFolder"
On error goto 0
Application.displayalerts = False
ThisWorkbook.SaveAs sDrive & ":\MyMacroFolder\" & thisworkbook.Name
Application.DisplayAlerts = True

--
Regards,
Tom Ogilvy



"Grandad" wrote in message
...
Tom

I'm sorry if I've not been clear.

I guess what I need is to be able to identify the default drive letter

for
each PC the macro is used on and to have a folder path to save a file

that
works on all PCs.

I hope that's a bit better tan my first attempt?

Mick


"Tom Ogilvy" wrote in message
...
If you have a path string:

Sub findDrive()
Dim fs As Object, f As Object
Dim sPath As String, drv As Object
Dim sPath1 As String
sPath = "Data\CSVDaily"
Set fs = CreateObject("Scripting.FileSystemObject")
For Each drv In fs.Drives
sPath1 = drv.DriveLetter & ":\" & sPath
On Error Resume Next
Set f = Nothing
Set f = fs.GetFolder(sPath1)
On Error GoTo 0
If Not f Is Nothing Then
MsgBox "found in drive " & drv.DriveLetter
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
What information do you have to start with? How would we know we

have
the
right drive?

Do you want to search all drives for a particular folder?

--
Regards,
Tom Ogilvy


"Grandad" wrote in message
...
Can anyone help with the code to first identify a drive letter on

PC
which
may also be different to the one on the PC that the macro was

built
on.
I
need to save a file to a specific folder path and if the drive

letter
is
different how to specify a folder path.

I hope that makes sense?

--
Kind Regards

Mick














  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help to Indentify a drive letter

Before you change anything, capture the name of the drive

sDriveStart = Left(curdir,1)

or if you want to know where the file was originally saved

sDriveSaved = Left(Thisworkbook.Path,1)



--
Regards,
Tom Ogilvy

"Grandad" wrote in message
...
Tom it's working more or less as I need it too so thanks for your help.

Having created the new folder is there a way to go back or identify the
original drive we started from?

Regards

Mick

"Tom Ogilvy" wrote in message
...
Dim sDrive as String
sDrive = left(curdir,1)
on error resume next
mkdir sDrive & ":\MyMacroFolder"
On error goto 0
Application.displayalerts = False
ThisWorkbook.SaveAs sDrive & ":\MyMacroFolder\" & thisworkbook.Name
Application.DisplayAlerts = True

--
Regards,
Tom Ogilvy



"Grandad" wrote in message
...
Tom

I'm sorry if I've not been clear.

I guess what I need is to be able to identify the default drive letter

for
each PC the macro is used on and to have a folder path to save a file

that
works on all PCs.

I hope that's a bit better tan my first attempt?

Mick


"Tom Ogilvy" wrote in message
...
If you have a path string:

Sub findDrive()
Dim fs As Object, f As Object
Dim sPath As String, drv As Object
Dim sPath1 As String
sPath = "Data\CSVDaily"
Set fs = CreateObject("Scripting.FileSystemObject")
For Each drv In fs.Drives
sPath1 = drv.DriveLetter & ":\" & sPath
On Error Resume Next
Set f = Nothing
Set f = fs.GetFolder(sPath1)
On Error GoTo 0
If Not f Is Nothing Then
MsgBox "found in drive " & drv.DriveLetter
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
What information do you have to start with? How would we know we

have
the
right drive?

Do you want to search all drives for a particular folder?

--
Regards,
Tom Ogilvy


"Grandad" wrote in message
...
Can anyone help with the code to first identify a drive letter

on
PC
which
may also be different to the one on the PC that the macro was

built
on.
I
need to save a file to a specific folder path and if the drive

letter
is
different how to specify a folder path.

I hope that makes sense?

--
Kind Regards

Mick














  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Help to Indentify a drive letter

Tom unfortunately it doesn't solve my problem. The situation is as follows:

A PC has a C:\ drive (or other local drive) and a P:\ on a server. When you
open my macro from the local drive the location the macro always seems to
point to is the P:\ drive. That's OK with what you have given me but have
done the business I need to get back to the local drive again.

Any ideas - you have done good so far Thanks

Mick

"Tom Ogilvy" wrote in message
...
Before you change anything, capture the name of the drive

sDriveStart = Left(curdir,1)

or if you want to know where the file was originally saved

sDriveSaved = Left(Thisworkbook.Path,1)



--
Regards,
Tom Ogilvy

"Grandad" wrote in message
...
Tom it's working more or less as I need it too so thanks for your help.

Having created the new folder is there a way to go back or identify the
original drive we started from?

Regards

Mick

"Tom Ogilvy" wrote in message
...
Dim sDrive as String
sDrive = left(curdir,1)
on error resume next
mkdir sDrive & ":\MyMacroFolder"
On error goto 0
Application.displayalerts = False
ThisWorkbook.SaveAs sDrive & ":\MyMacroFolder\" & thisworkbook.Name
Application.DisplayAlerts = True

--
Regards,
Tom Ogilvy



"Grandad" wrote in message
...
Tom

I'm sorry if I've not been clear.

I guess what I need is to be able to identify the default drive

letter
for
each PC the macro is used on and to have a folder path to save a

file
that
works on all PCs.

I hope that's a bit better tan my first attempt?

Mick


"Tom Ogilvy" wrote in message
...
If you have a path string:

Sub findDrive()
Dim fs As Object, f As Object
Dim sPath As String, drv As Object
Dim sPath1 As String
sPath = "Data\CSVDaily"
Set fs = CreateObject("Scripting.FileSystemObject")
For Each drv In fs.Drives
sPath1 = drv.DriveLetter & ":\" & sPath
On Error Resume Next
Set f = Nothing
Set f = fs.GetFolder(sPath1)
On Error GoTo 0
If Not f Is Nothing Then
MsgBox "found in drive " & drv.DriveLetter
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
What information do you have to start with? How would we know

we
have
the
right drive?

Do you want to search all drives for a particular folder?

--
Regards,
Tom Ogilvy


"Grandad" wrote in message
...
Can anyone help with the code to first identify a drive letter

on
PC
which
may also be different to the one on the PC that the macro was

built
on.
I
need to save a file to a specific folder path and if the drive
letter
is
different how to specify a folder path.

I hope that makes sense?

--
Kind Regards

Mick
















  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help to Indentify a drive letter

Sub findDrive()
Dim fs As Object, f As Object
Dim sPath As String, drv As Object
Dim sPath1 As String, dType As String
Set fs = CreateObject("Scripting.FileSystemObject")
For Each drv In fs.Drives
dType = ShowDriveType(fs, drv)
If dType = "Network" Then
dShare = drv.ShareName
Else
dShare = ""
End If
Debug.Print drv.DriveLetter & " - " & dType & _
IIf(dShare < "", " - " & dShare, "")
Next
End Sub

Function ShowDriveType(fso, drv)
Dim d, t
Set d = drv
Select Case d.DriveType
Case 0: t = "Unknown"
Case 1: t = "Removable"
Case 2: t = "Fixed"
Case 3: t = "Network"
Case 4: t = "CD-ROM"
Case 5: t = "RAM Disk"
End Select
ShowDriveType = t
End Function



will list the drive letters and the drive type.

Perhaps that will give you what you want.

You can also look at Application.Path

? left(Application.Path,1)
C

--
Regards,
Tom Ogilvy

"Grandad" wrote in message
...
Tom unfortunately it doesn't solve my problem. The situation is as

follows:

A PC has a C:\ drive (or other local drive) and a P:\ on a server. When

you
open my macro from the local drive the location the macro always seems to
point to is the P:\ drive. That's OK with what you have given me but have
done the business I need to get back to the local drive again.

Any ideas - you have done good so far Thanks

Mick

"Tom Ogilvy" wrote in message
...
Before you change anything, capture the name of the drive

sDriveStart = Left(curdir,1)

or if you want to know where the file was originally saved

sDriveSaved = Left(Thisworkbook.Path,1)



--
Regards,
Tom Ogilvy

"Grandad" wrote in message
...
Tom it's working more or less as I need it too so thanks for your

help.

Having created the new folder is there a way to go back or identify

the
original drive we started from?

Regards

Mick

"Tom Ogilvy" wrote in message
...
Dim sDrive as String
sDrive = left(curdir,1)
on error resume next
mkdir sDrive & ":\MyMacroFolder"
On error goto 0
Application.displayalerts = False
ThisWorkbook.SaveAs sDrive & ":\MyMacroFolder\" & thisworkbook.Name
Application.DisplayAlerts = True

--
Regards,
Tom Ogilvy



"Grandad" wrote in message
...
Tom

I'm sorry if I've not been clear.

I guess what I need is to be able to identify the default drive

letter
for
each PC the macro is used on and to have a folder path to save a

file
that
works on all PCs.

I hope that's a bit better tan my first attempt?

Mick


"Tom Ogilvy" wrote in message
...
If you have a path string:

Sub findDrive()
Dim fs As Object, f As Object
Dim sPath As String, drv As Object
Dim sPath1 As String
sPath = "Data\CSVDaily"
Set fs = CreateObject("Scripting.FileSystemObject")
For Each drv In fs.Drives
sPath1 = drv.DriveLetter & ":\" & sPath
On Error Resume Next
Set f = Nothing
Set f = fs.GetFolder(sPath1)
On Error GoTo 0
If Not f Is Nothing Then
MsgBox "found in drive " & drv.DriveLetter
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
What information do you have to start with? How would we know

we
have
the
right drive?

Do you want to search all drives for a particular folder?

--
Regards,
Tom Ogilvy


"Grandad" wrote in message
...
Can anyone help with the code to first identify a drive

letter
on
PC
which
may also be different to the one on the PC that the macro

was
built
on.
I
need to save a file to a specific folder path and if the

drive
letter
is
different how to specify a folder path.

I hope that makes sense?

--
Kind Regards

Mick


















Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Obtain drive letter assignment of CD/DVD drive? EagleOne Excel Discussion (Misc queries) 1 October 13th 06 01:27 PM
Can I show server name instead of drive letter? bfant Excel Discussion (Misc queries) 9 February 17th 05 06:11 AM
Using path instead of drive letter dumbass Excel Programming 2 May 25th 04 12:25 AM
Drive Letter of current file zSplash Excel Programming 6 April 28th 04 03:21 PM
How to find the drive letter? Mervyn Thomas Excel Programming 8 January 31st 04 01:11 PM


All times are GMT +1. The time now is 04:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"