"Dave Peterson" wrote:
> You could search the *scripting* newsgroups via google:
....
> That pointed to:
> http://groups.google.co.uk/group/mic...9?dmode=source
> and
> http://groups.google.co.uk/group/mic...2?dmode=source
>
>
>
>
> WLMPilot wrote:
> >
> > Is there a way to determine what drive is assigned to my memory stick.
> > Instead of having to "explore", then drag and drop my spreadsheets between my
> > computer and memory stick, I want to use a command button to save it to the
> > memory stick.
> >
I think that sample code does not distinguish between memory sticks and
external disks. Maybe it would be simpler to rename the memory stick (if
possible) and check for volume name, something like this:
Set fso = CreateObject _
("Scripting.FileSystemObject")
Set colDrives = fso.Drives
For Each objDrive In colDrives
If objDrive.IsReady Then
If objDrive.VolumeName = "MYUSBDRIVE" Then
Debug.Print objDrive.Path, _
objDrive.VolumeName, _
objDrive.DriveType
End If
End If
Next
or using WMI:
Set WMI = GetObject _
("WinMgmts:Root\Cimv2")
Set colLogicalDisks = WMI.ExecQuery _
("Select * From Win32_LogicalDisk " & _
"Where VolumeName = 'MyUSBDrive'")
For Each objLogicalDisk In colLogicalDisks
Debug.Print objLogicalDisk.DeviceID, _
objLogicalDisk.VolumeName, _
objLogicalDisk.Description
Next
--
urkec